23

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

Community
  • 1
  • 1
IAmJulianAcosta
  • 1,082
  • 2
  • 14
  • 30
  • Possible duplicate of [create multiple tag docker image](http://stackoverflow.com/questions/21928780/create-multiple-tag-docker-image) – RisingSun Jan 25 '16 at 20:13

2 Answers2

39

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

Mark Riggins
  • 471
  • 4
  • 5
3

Yes, it's possible with docker commit, as documentation says..

Create a new image from a container’s changes

Checkout reference in..

https://docs.docker.com/engine/reference/commandline/commit/

docker commit [CONTAINER_ID]  [REPOSITORY]/[TAG]
50qbits
  • 254
  • 2
  • 3
  • 1
    I don't think that this answer is correct. As the documentation that you link to says, the `docker commit` command creates a new image and tags the new image. IAmJulianAcosta says in his question that he wants to tag containers, **not images** so you cannot use `docker commit` – aalbagarcia Nov 13 '20 at 12:30