In this blog post, I will show you how to create a Docker image using a Dokckerfile running on a Linux CentOS host.
On a high level, a Dokcerfile is a runbook with a set of instructions that together build a Docker image.
Using a Dockerfile we streamline the entire process of building images.
The first step in creating a folder where we will put our Dockerfile in.
In my case, I will create a folder called build01
Create a Dockerfile
Next, I will create a Dockerfile using the following command:
Note: The file can be start with or without a capital d.
Below you can see the actual Dockerfile content.
RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo | tee /etc/yum.repos.d/microsoft.repo
RUN yum install -y powershell
The image is based on the latest CentOS docker image and will install PowerShell 7.
To build the image, I will run the following command and at the end, I will have an image called powershell-v1.
docker build -t powershell-v1 .
When I run the docker images command I will see it listed.
To deploy my image, I will run the following command:
docker container run -it powershell-v1