From what I can find, "cocky" originally was derived from "cock" which originally mean a male chicken, and only later became a slang term for penis. (Proving to me that men will nickname their anatomy after ANYTHING.)
And, interesting, due to "cock" becoming more commonly used for "penis" than for "rooster", "cocky" is now becoming a bad word, whereas originally it was quite innocent.
http://www.reference.com/search?q=cock
Unless you're from Australia, in which case "cocky" can mean a cockatiel. Which also struts around as if it knows everything.