This poem by Walt Whitman was written upon the death of Abraham Lincoln, who was assassinated on April 14, 1865, a scant five days after the official end of the Civil War on April 9, 1865. Lincoln is indeed the captain referred to in the poem, which is an extended metaphor, America being the ship, Lincoln being its captain, and the Civil War being the journey.
As the poem opens, the narrator is addressing the captain of the ship, i.e., the leader of the country, saying that the dreadful journey, which is a metaphor for the Civil War, is done. The captain and the country are victorious and the worst is over. The country can get on with the business of being a nation again. But the captain of the ship lies on the deck, bleeding and dying.
In the second verse, the narrator is telling the captain that everyone is celebrating the end of the voyage, the end of war, and everyone is calling for the captain, their father, who has led them through this voyage successfully, praising him for having saved the ship, in other words, the nation. But the captain lies there, with the narrator's arm beneath his head. It is like a nightmare to the narrator and to the country that the captain is now dead.
In the third verse, the narrator says the captain doesn't answer because he is gone, and while the voyage is over and the ship is soundly and safely at anchor, the narrator and the country must mourn the loss of the captain who has guided the ship to this victorious point.
My father read and recited a great deal of poetry when we were children, and this poem was one that we often requested. Even at a young age, we understood this metaphor, the president of a country being the captain of a ship, and even with its tragic subject and mournful tone, it appealed to us.