When you create a container from a Python image in Docker, in which operating system does Python work?

Asked 2 years ago, Updated 2 years ago, 61 views

I'm trying to build a Python environment with Windows 10 home + WSL2 (Ubuntu) + Docker for Windows (+Vscode).

After studying how to build a Python environment in Docker, I think there are two main ways to write dockerfile.
One is to create a ubuntu container before installing python, as described in https://blauthree.hatenablog.com/entry/2019/07/13/000839.

# Base image
FROM ubuntu —18.04

# Run on container creation on RUN
RUN apt-get update
RUN apt-get install-y python3 python3-pip

Another way is to pull the python image to create a container.

FROM python:3
USER root

RUN apt-get update
RUN apt-get-y install locations & \
    localizedef-f UTF-8-ija_JPja_JP.UTF-8

I have a feeling that the former installs ubuntu and Python runs on that OS, but which OS does Python run on the latter?Does it work based on Ubuntu installed as WSL2 or does it have some kind of OS built into the python::3 image that is being pulled from docker hub?

Also, is there simply an indicator of which is more appropriate?

I'm sure it's an incredible beginner's question, but I'd appreciate it if you could answer it.

ubuntu docker wsl

2022-09-30 10:14

1 Answers

As far as https://hub.docker.com/_/python, the operating system looks like Debian (Linux) when python:<version> is specified.

Also, if you change the designation, you can choose Alpine Linux or Windows Server Core.

The choice of base image depends on what you want first.

If you choose Ubuntu (OS) as your base, the Python package you put in later will be limited to the one provided by the OS.(Not always the latest Python)

Python images can be selected in more detail, including minor versions, so this may be more convenient if you need a specific Python version of the reproduction environment.


2022-09-30 10:14

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.