Let us remember that a metaphor is a figure of speech that asserts a direct comparison between two objects that are not normally considered similar without the use of the words "like" or "as," as in a simile, which is the same except for the addition of these words. There are two kinds of metaphors in literature, direct metaphors, where the comparison is directly asserted, such as "the flower was a ray of light in a dark day," and indirect metaphors, where the comparison is inserted much more subtlely, such as "the teacher barked out his commands." Here you can see that the teacher is being compared to a dog through the indirect metaphor.
When we think of the dying soldier, we see that the metaphor used to describe his manner of dying relates to the green panels of the gas mask through which the poet sees him:
Dim, through the misty panes and thick green light,
As under a green sea, I saw him drowning.
Note how there is an indirect metaphor in the word "drowning," which compares the way the soldier dies from the gas to a man drowning in the sea.