2

I have read this question and I understand that you need some kind of foundation to build your docker image. However, I still don't see the purpose of docker images like python.

Why do I need this:

FROM python:latest

when I can just do that:

FROM ubuntu
RUN apt install python3

Say I want to run a container where a python server is hosted using apache. What would be the difference between

  1. Using the apache base image and installing python manually
  2. Using the python base image and installing apache manually
  3. Using the ubuntu base image and installing both manually
Jan Berndt
  • 913
  • 1
  • 10
  • 22
  • In principle there is no difference but the details of each image may vary. – mkrieger1 Feb 07 '21 at 14:54
  • You can actually check out what's in the python image [here](https://github.com/docker-library/python/blob/afc4106edc395bed8dfe7a497444033b12452406/3.9/buster/Dockerfile) – timsmelik Feb 07 '21 at 15:02

1 Answers1

2

The difference is slim in the given example because in the end you will get the same thing but using slightly different commands.

Things change when you need to use either latest or specific version of the software. The required version may not be available in standard Ubuntu repositories or may come with a delay.

What you get from using python or apache2 as a base is the ability to choose the version you need with just one line of code as soon as it's published.

More significantly, there may be no need to combine python and apache. Docker containers are usually made to host a single process and it is more common to have a python backend in one container and a web-server as a proxy in another.

In this case you don't care about installing apache at all, you just mount its config into the container at runtime. Eliminating the web server you only need to focus on the application and its dependencies, so in the end you will have less code and easier time maintaining it.

anemyte
  • 17,618
  • 1
  • 24
  • 45