Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42642

Good way to pick a TAG for Dockerfile

I was wondering, what is some good ways, to decide which TAG for Dockerfile.

For instance, I'm clear on my requirement.

  1. I need Python 3.6
  2. I need Alpine distribution due to its small size.

Should I pick

FROM python:3.6.6-alpine3.8

or

FROM python3.6-alpine

Upvotes: 0

Views: 89

Answers (1)

norbjd
norbjd

Reputation: 11237

Even if python:3.6-alpine is an alias for python:3.6.6-alpine3.8, generally (but it's a personal preference), I tried to be as precise as possible when choosing a base image, so I would rather use python:3.6.6-alpine3.8.

It avoids misunderstanding for people reading the Dockerfile, and for people using the image, like :

Oh! Why's that library not available in the image? Maybe because of Alpine version? By the way, what's the Alpine version? I'm going to check /etc/alpine-release to see...

For Python version, it's more complicated because using 3.6.6 tag, your build can eventually fail in the future if a 3.6.7 version is released; indeed, by looking Python images versions on Docker store, only images with the latest fix version seems to be kept. But all depends if your image will need to be rebuilt, or if it's just pushed once to your own registry and then used as a base image. If regular builds are expected, in that particular case, I would maybe use 3.6-alpine3.8, because, normally, fix versions does not remove compatibility and just add small improvements/bug fixes.

In short, it does not cost anything to be precise when choosing a tag and saves a lot of explanation when the image is used : you know exactly what's in the base image you extend, just by reading the Dockerfile. But be careful if those tags have a short life expectancy.

Upvotes: 1

Related Questions