This poem is set on a ship that’s coming into harbor. Of course, for Whitman, this was much more than a ship. This was the U.S.S. America he was talking about (for more on the importance of the ship, see “Symbolism, Imagery, Allegory”). The symbolic nature of a captain bringing his ship safely into harbor was too much for Whitman to pass up, and he milks the analogy for all that it’s worth.
The president of the country is easily converted to a captain, just as the country as a whole is understood to be the ship. The harbor is a bit more abstract, but the safety it affords can be seen as the peace that was achieved at the end of the Civil War. Finally, the teeming crowds that cheer the ship from the shore represent the entirety of the American population. In short, each aspect of the setting has a symbolic significance that Whitman uses to mourn and celebrate Abraham Lincoln. (For more on this, check out “Symbolism, Imagery, Allegory.”)