Dwarves
Memo
Type ESC to close search bar

Unstable Package Installation in Docker

For example, lets suppose that we have following Dockerfile.

FROM ubuntu:20.04
RUN apt-get update && apt-get install -y python3

Imagine that the first time you build your Docker image, the version of Python is 3.8.1. However, today when the latest version of Python is 3.9.1, you want to build Docker image again. Transparently, your two images are different no matter that you are using the same Dockerfile. It means you can’t reproduce the same environment where your application is running.

If you are familiar with Docker, it is more than one solution pops into your mind. The easiest way is to specify a specific version to install like the following.

FROM ubuntu:20.04
RUN apt-get update && apt-get install -y python3=3.8.10-0ubuntu1~20.04.1

In this way, the instability can be decreased but can not resolve the issue completely. The reasons can be listed as follows.

We have some keywords related to better solutions that I only list here for reference.