I'm creating an app when I have several kind of containers, and I want to know if docker has some way of tagging containers (example: database, data-only ...).
Note: This answer is about giving names to containers instead of tags. I'm asking to giving arbitrary tags to containers, not images
Docker tags are just an alias for an image ID. The tag's name must be an ASCII character string and may include lowercase and uppercase letters, digits, underscores, periods, and dashes. In addition, the tag names must not begin with a period or a dash, and they can only contain 128 characters.
Docker tags are mutable named references to Docker images, much like branch refs in Git. They make it easy to pull and run images, and for image authors to roll out updates automatically. For example, to pull the latest Debian GNU/Linux image for the buster release: $ docker pull debian:buster.
Latest is Just a Tag It's just the tag which is applied to an image by default which does not have a tag. Those two commands will both result in a new image being created and tagged as :latest: # those two are the same: $ docker build -t company/image_name . $ docker build -t company/image_name:latest .
I think you may be confusing some Docker terminology. Here's a brief list of similar-yet-confusing terms
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With