Create Ubuntu and Python Docker Containers

Although you can pull a Ubuntu image from the Docker Hub using the ” docker pull ubuntu”, it is more flexible to create your Ubuntu as you can specify the Ubuntu version and install any software you want such as Python 3 on your Mac or Window using Docker. In the following example, we will show how to install Ubuntu 20.04 with Python 3 using Docker.

First, create a folder, say called it first.

Create a Dockerfile and add the following lines

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

Build a docker image on the cmd line as follows

docker build first -t first

A docker image named first is then created. You can start the docker container as follows:

docker run -it first
Output: root@4249d676bf47:/#


Relevant Courses

June 6, 2021