DEV Community

KIranuknow
KIranuknow

Posted on

How to install python in a docker container.

Pull the Ubuntu Docker Image:

First, download the official Ubuntu Docker image from the Docker Hub by running the following command:

docker pull ubuntu
Enter fullscreen mode Exit fullscreen mode

Start an Interactive Container:

Create an interactive container based on the Ubuntu image:

docker run -it ubuntu /bin/bash
Enter fullscreen mode Exit fullscreen mode

You’ll be logged in as the root user inside the container.
Update the Container: Update the package lists within the container:

apt-get update
Enter fullscreen mode Exit fullscreen mode

Install Python: For Python 3.x, run:

apt-get install python3
Enter fullscreen mode Exit fullscreen mode

Exit the Container: Type exit to leave the container.

Top comments (0)