With Docker 1.6, a feature has been added so that we can label containers and images through which we can attach arbitrary key-value pairs as metadata. You can think of them as environment variables, that are not available for applications running inside containers, but they are available to Docker clients that manage the images and containers. Labels attached to images also get applied to containers that are started using those images. We can also attach labels to containers while starting them. Having labeled an image or a container, the labels can later be used for filtering or selection purposes.
For this recipe, let's assume that we have an image with the label com.example.image=docker-cookbook. We will see how to assign a label to an image in the next chapter:
As you can see from the preceding screenshot, if we use filters with the...