MRocklin
MRocklin

Reputation: 57301

Tag docker files with build numbers

I would like to publish docker images tagged with both semantic versions (like version 1.0) and also build numbers (like build 3). Operationally this might come about in the following way:

docker build -t my-project:1.0-1
# make minor changes to docker file
docker build -t my-project:1.0-2
# make minor changes to docker file
docker build -t my-project:1.0-3
# release new version of project
docker build -t my-project:1.1-1

I would expect some users to pin to particular build numbers

docker pull my-project:1.0-2

While other users would just ask for "the lastest of version 1.0"

docker pull my-project:1.0

Does this work? Is there a better way to accomplish this goal?

Upvotes: 2

Views: 491

Answers (1)

bluescores
bluescores

Reputation: 4677

Yes, this works. A tag is just a friendly name attached to an image ID. Any given image can have as many tags as you would realistically want.

docker tag myproject my-project:1.0-2
docker tag myproject my-project:1.0

Then, if you docker images and find these tags, you'll see that the IMAGE ID for both tags is the same. Keep in mind you'd want to push both tagged images to your repository.

Looking at a couple of popular Docker Hub repos for inspiration: ruby, python, postgres

Upvotes: 3

Related Questions