Base image with specific version in Dockerfile, TRUE or FALSE ?

Payam Saderi
Macellan
Published in
2 min readJan 26, 2023

--

When we start creating Dockerfile, first thing we choose is the base image, rather than selecting image’s Linux distro like Ubuntu or Alpine. We need to pick version, normally we didn’t care about patch version and pick base image with general version.

FROM php:8.1-bullseye

But using an exact version of the base image can be beneficial in certain situations. Here are a few reasons why you might want to use an exact version of the base image when building a containerized application:

Compatibility

If your application depends on specific versions of libraries or other dependencies, using an exact version of the base image can help ensure that these dependencies are present and compatible with your application.

Security

By using an exact version of the base image, you can ensure that your application is running on a known-good version of the base image. This can help you to avoid security vulnerabilities that might have been introduced in newer versions of the base image.

Reproducibility

By using an exact version of the base image, you can ensure that your application runs consistently across different environments. This is particularly important if you are deploying your application to multiple environments, such as development, staging, and production.

Support

If you are using a specific version of the base image, you can ensure that you can find support and documentation for that version. If you’re using a latest version, it might not be supported or have documentation yet.

That being said, using an exact version of the base image also has some downsides. For example, your application might not be able to take advantage of new features or improvements in newer versions of the base image. Additionally, using an exact version can make it more difficult to keep your application up to date with security patches and other updates.

Be careful when using this double edged sword :)

Ultimately, whether you use an exact version of the base image or a more general version will depend on your specific needs and constraints. It’s a good idea to weigh the benefits and drawbacks of each option and choose the one that works best for your application.

--

--

Now I am a DevOps engineer! I started to work as a front-end developer in 2000, aslo I have more than 16 years of experiences as a Linux system administrator