Question : The Nautilus DevOps team is working to create new images per requirements shared by the development team. One of the team members is working to create a Dockerfile on App Server 1 in Stratos DC. While working on it she ran into issues in which the docker build is failing and displaying errors. Look into the issue and fix it to build an image as per details mentioned below:
a. The Dockerfile is placed on App Server 1 under /opt/docker directory.
b. Fix the issues with this file and make sure it is able to build the image.
c. Do not change base image, any other valid configuration within Dockerfile, or any of the data been used — for example, index.html.
Note: Please note that once you click on FINISH button all existing images, the containers will be destroyed and new image will be built from your Dockerfile.
Solution:
1. Login on app server as per the task & Switch to root user
|
2. Run the below command to check existing docker images
root@stapp01 ~]#
docker images REPOSITORY TAG
IMAGE ID CREATED SIZE [root@stapp01
~]# |
3. Edit vi Dockerfile under /opt/docker directory ( Refer Video post below )
[root@stapp01
~]# cd /opt/docker [root@stapp01
docker]# vi Dockerfile [root@stapp01
docker]# cat Dockerfile FROM
httpd:2.4.43 RUN sed -i "s/Listen 80/Listen 8080/g" /usr/local/apache2/conf/httpd.conf RUN sed -i '/LoadModule\ ssl_module modules\/mod_ssl.so/s/^#//g' /usr/local/apache2/conf/httpd.conf RUN sed -i '/LoadModule\ socache_shmcb_module modules\/mod_socache_shmcb.so/s/^#//g' /usr/local/apache2/conf/httpd.conf RUN sed -i '/Include\ conf\/extra\/httpd-ssl.conf/s/^#//g' /usr/local/apache2/conf/httpd.conf COPY certs/server.crt /usr/local/apache2/conf/server.crt COPY certs/server.key /usr/local/apache2/conf/server.key COPY html/index.html /usr/local/apache2/htdocs/ [root@stapp01
docker]# |
[root@stapp01
docker]# docker build -t httpd_image . Sending build
context to Docker daemon 9.216kB Step 1/8 : FROM
httpd:2.4.43 2.4.43: Pulling
from library/httpd bf5952930446:
Pull complete 3d3fecf6569b:
Pull complete b5fc3125d912:
Pull complete 3c61041685c0:
Pull complete 34b7e9053f76:
Pull complete Digest:
sha256:cd88fee4eab37f0d8cd04b06ef97285ca981c27b4d685f0321e65c5d4fd49357 Status:
Downloaded newer image for httpd:2.4.43 ---> f1455599cc2e Step 2/8 : RUN
sed -i "s/Listen 80/Listen 8080/g"
/usr/local/apache2/conf/httpd.conf ---> Running in 45063dc65604 Removing
intermediate container 45063dc65604 ---> 09bd9755cfaa Step 3/8 : RUN
sed -i '/LoadModule\ ssl_module modules\/mod_ssl.so/s/^#//g'
/usr/local/apache2/conf/httpd.conf ---> Running in 648760d30831 Removing
intermediate container 648760d30831 ---> de6b024890be Step 4/8 : RUN
sed -i '/LoadModule\ socache_shmcb_module
modules\/mod_socache_shmcb.so/s/^#//g'
/usr/local/apache2/conf/httpd.conf ---> Running in 3416bae86d9d Removing
intermediate container 3416bae86d9d ---> 3942c7f4cf11 Step 5/8 : RUN
sed -i '/Include\ conf\/extra\/httpd-ssl.conf/s/^#//g'
/usr/local/apache2/conf/httpd.conf ---> Running in a09bc65333bd Removing
intermediate container a09bc65333bd ---> 3c91a7b7f7e7 Step 6/8 : COPY
certs/server.crt /usr/local/apache2/conf/server.crt ---> 391d11b244d6 Step 7/8 : COPY
certs/server.key /usr/local/apache2/conf/server.key ---> c5103b38aa92 Step 8/8 : COPY
html/index.html /usr/local/apache2/htdocs/ ---> 94b87dd5abf9 Successfully
built 94b87dd5abf9 Successfully
tagged httpd_image:latest [root@stapp01
docker]# |
[root@stapp01
docker]# docker images REPOSITORY TAG
IMAGE ID CREATED SIZE httpd_image latest
94b87dd5abf9 About a minute
ago 166MB httpd 2.4.43 f1455599cc2e 12 months ago 166MB [root@stapp01
docker]# |
6. Click on Finish & Confirm to complete the task successful
Happy Learning!!!!
0 Comments