Build a Docker image on a Linux Machine

In this blog post,  I will show you how to build a Docker image using a dockerfile on  Linux machine.

Docker Build

We use the docker build command to create a Docker image using a file that contains build instruction.

The file that contains the instructions is called Dockerfile.

 DockerFile

Let’s create a Dockerfile using the following command.

nano dockerfile

Content

In the Docker file I will copy the following lines which will build the image.

FROM python
RUN mkdir c:\app
COPY  Password_generator_class.py /app/Password_generator_class.py
CMD python /app/Password_generator_class.py

Docker Build Command

The next step is building the image using the following command.

Note: Make sure you run it from the same folder the dockerfile is located.

 docker build --tag passwordgenerator .

Check Image

After the build process is completed, run the following command to check that the image is available.

docker images