As all good sayings do, it comes from a sailor.
The following is an excerpt from Memoirs of Serjeant Paul Swanston: being a narrative of a soldier's life, in barracks, ships, camps, battles, and captivity on sea and land; with notices of the most adventurous of his comrades. (no, that's really the full name of the book), first published in 1818.
In quick time they were at the wine-pipe; for a moment the new hands seemed at a loss for the means of getting the wine to their mouths; but the "wide-a-awake" boy sliped (sic) off one of his shoes in a twinkling, dipped it into the cask and drank.
"Drink, you devils, drink!" he said; "its all one how much you drink, only don't get drunk!" And again he filled his shoe, and again he drank. The previous debauch in connexion with the new, soon tumbled him on the ground; and he lay there gradually sinking into stupidity; but, as he took his leave of consciousness, he admonished the others to take care of themselves; to take as much as they could rightly carry; but not to get drunk, saying, as he sunk lower and lower himself, "Fill your boots, boys—fill your boots! Give me one small drop in a shoe to make me well again, for I'm— I'm—."
Alas, poor humanity! There lay in the deepest degradation, as good a fighting soldier, and, when he could not get drink, as cleanly and active a fellow as ever the English army possessed.
I can't think of anything more exemplary of gusto than a sailor getting blind stinking drunk out of his shoe.
You can read the full text here.