In this blog, I will be creating image using Docker file. I will be using rhel7 as base image
1. Create a directory called ‘mytest’ and change to it. In this directory, create an empty file called “Dockerfile”.
[user@mytest:~]$ mkdir mytest
[user@mytest:~]$ cd mytest
[user@mytest:mytest/]$ touch Dockerfile
2. Edit the “Docker file, and make the following changes
– Use the base image of Rhel7 from the repository
– Provide the email id as the author and maintainer of this images
– Update the base OS using yum
– Install open-ssh
– Install Apache service
– Expose port 80 and 22
[user@mytest:mytest/]$ vi Dockerfile
#Pull the base image of rhel7
FROM rhel:rhel7
#Provide author name and maintainer
MAINTAINER amit <contact@openwriteup.com>
#Update the base image
RUN yum -y upgrade
#Install the apache package
RUN yum -y install httpd
#Install openssh
RUN yum -y install openssh-server
#Open the port
EXPOSE 22 80
[user@mytest:mytest/]$ docker build -t mybuild/withservice:v1 .
(Output) NOTE: Yours will differ slightly, FULL output listed here for reference
Sending build context to Docker daemon 2.048 kB
Sending build context to Docker daemon
Step 0 : FROM rhel:rhel7
—> a005304e4e74
Step 1 : MAINTAINER amit<contact@openwriteup.com>
—> Running in c12b9039f6ee