andyfinch
andyfinch

Reputation: 1332

Docker image repository name or tag for environment versioning

Was hoping to get some advice for the best approach for creating Docker images for deployment over several environments. Assuming we have 3 environments - DEV, UAT & PRD would it be best to name the image accordingly along with a version tag i.e.

my-service-dev:release-10
my-service-uat:release-8
my-service-prd:release-6

or keep the repository the same but use the tag:

my-service:dev-release-10
my-service:uat-release-8
my-service:prd-release-6

We are using Bamboo as a build/deploy pipeline so can easily append build/release variables.

Any advice much appreciated.

Upvotes: 3

Views: 2565

Answers (1)

David Maze
David Maze

Reputation: 158647

Usually you should use the same image in all environments, so that when you push an image to production you're running the exact code you ran in the test environment. You don't need text like "release" in the tag either, and if you look at standard Docker Hub images it's common enough for the tag to just be a number.

my-service:10

If your CI system can generate sequential build numbers these can work fine. If developers are building test images themselves it may be more convenient to use a time stamp or source control commit ID.

my-service:20201111
my-service:g52fc7a0

If you really need different builds in different environments, standard Docker Hub images encode details like that in tags. For example, the python image has variants python:3.9-alpine and python:3.9-buster (Debian). Often a top-level image name is a "unit" in a registry; you might need to use a tool like Terraform to create a new image name in AWS ECR, but you can push arbitrarily many tags once the image name exists.

my-service:10-test
my-service:11-prod

Upvotes: 5

Related Questions