How to tag a docker container?

I think you may be confusing some Docker terminology. Here's a brief list of similar-yet-confusing terms

  • Repository -- a name for a set of images such as 'nginx'
  • Image -- one binary image such with an id such as 407195ab8b07
  • Tag -- a user-defined name for 407195ab8b07 such as 'nginx:1.9.9'
  • Container -- a runnable process the executes the image
  • Label -- a user-defined name/value pair for an image or container

An image can have many tags and labels -- but these are set AT BUILD TIME

Think of an image as a CD or DVD disk for your Xbox -- its a bunch of binary information.

Many containers can be run for an image -- each container runs in its own virtual process and has its own file system, environment.

Think of the container as a Video Game playing on your Xbox -- it's moving and "running" -- a container "runs" an image. So to create the image you say docker run and give it the name of the image to run

docker run nginx:1.9.9

Containers can be named when they are created

docker run --name MyNginx nginx:1.9.9

The container name can be used to stop the container:

docker stop MyNginx

Containers can also have labels added at start-time

docker run --label "foo=BAR" nginx:1.9.9 

Hope this helps

Tags:

Docker