You are on page 1of 5

Docker With Python:

PART1: Build Images

Step1: Create a Python App (Below is the sample flask app I have)

Step2: Test the application(Optional)


Step3: Create a Docker file for Python
Now we have an application, you can use docker init to create a Dockerfile for it. Inside the python-
docker directory, run the docker init command. Refer to the following example to answer the prompts
from docker init

After this step you could see the below mentioned 3 files in your directory,
1. DockerFile

2. .dockerignore
3. Compose.yaml

Step4: Build an Image


View Local Images:

To create a new tag for the image you built:

To delete a tag:

PART2 – Run your Image as a Container


What is Containers?
 Runtime instance of an image (or)At the time of executing the image, it is converted
into a Container.
 Can create multiple containers for a single image.
 A container is a normal operating system process except that this process is isolated in
that it has its own file system, its own networking, and its own isolated process tree
separate from the host.

To Run the image as a container:

You might also like