Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python base image vs Ubuntu base image installing python separately in docker

I just started leaning docker to apply it to my application. While I am doing, I have had question. Please understand it could be trivial question though. I am very new at docker.

Intuitively using an OS(ubuntu) image as base seems more heavy than just pure python relatively.

That has been why I always try to use just python image as base even though there are some use cases with ubuntu.

However, I found even I use python image as base for a container It still can run Linux(Ubuntu) commands like apt-get, ls, ps and have a file system structure like as ubuntu(home, root , usr).

It looks still tiny OS like ubuntu.

I know If I use just ubuntu image I should set up the environment manually by contrast with python image.(If all I want is running python)

Except for convenience aspect, Do they have any difference giving a reason I should use python other than ubuntu for example stability and performance?

like image 347
SangminKim Avatar asked Nov 01 '17 02:11

SangminKim


People also ask

Does Ubuntu Docker image include Python?

Ubuntu and RHEL have backported newer versions of Python, so even though they are older than Debian 11 they still include Python 3.9.

Does Docker image include base image?

A Docker image has many layers, and each image includes everything needed to configure a container environment -- system libraries, tools, dependencies and other files. Some of the parts of an image include: Base image. The user can build this first layer entirely from scratch with the build command.

Can Docker have multiple base images?

In later versions of Docker, it provides the use of multi-stage dockerfiles. Using multi-stage dockerfiles, you can use several base images as well as previous intermediate image layers to build a new image layer.

Why do we need a base image in Docker?

A base image is the image that is used to create all of your container images. Your base image can be an official Docker image, such as Centos, or you can modify an official Docker image to suit your needs, or you can create your own base image from scratch.


1 Answers

You can read about the python image in its documentation

The interesting part is:

This tag is based off of buildpack-deps. buildpack-deps is designed for the average user of docker who has many images on their system. It, by design, has a large number of extremely common Debian packages.

And buildpack-deps itself can be based on either Debian, or Ubuntu image.

As they mention in the documentation - if you don't have specific requirements, or don't know why you'd not use another image, then python is a good choice.

In the future, you may be interested in other images if you for example want to have your deployment image smaller than the one testing with (which may have some extra tools). Or in general you could be tempted to use the smallest size possible to remove unnecessary utilities. There are reasons to do each of these - you'll likely figure out yourself at what point these matter to you.

like image 104
viraptor Avatar answered Sep 22 '22 07:09

viraptor