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 3 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 3 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 the existing containers will be destroyed and new image will be built from your Dockerfile.

# ssh in as normal
# Review Dockerfile in /opt/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' conf/httpd.conf
RUN sed -i '/LoadModule\ socache_shmcb_module modules\/mod_socache_shmcb.so/s/^#//g' conf/httpd.conf
RUN sed -i '/Include\ conf\/extra\/httpd-ssl.conf/s/^#//g' conf/httpd.conf
COPY /server.crt /usr/local/apache2/conf/server.crt
COPY /server.key /usr/local/apache2/conf/server.key
COPY ./index.html /usr/local/apache2/htdocs/[banner@stapp03 docker]$

Issues causing the Docker build to fail are:
- Wrong path for conf/httpd.conf  -- this should use the full path
- COPY /server.crt means copy from absolute path on build host -no leading / is required. Ensure that certs are being copied from certs and the index.html file is being copied from html

New Dockerfile should be as follows:

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' 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/

Build the image:

cd /opt/docker - If not already in the directory
docker build -t custom-httpd:latest .

+] Building 108.9s (13/13) FINISHED                                              docker:default
 => [internal] load build definition from Dockerfile                                        0.0s
 => => transferring dockerfile: 595B                                                        0.0s
 => [internal] load metadata for docker.io/library/httpd:2.4.43                            30.2s
 => [internal] load .dockerignore                                                           0.0s
 => => transferring context: 2B                                                             0.0s
 => [internal] load build context                                                           0.0s
 -- snipped -- 
  => => writing image sha256:0874d8af07a2f74663c8246496891923d550a5285b176958a9117e0a6a0cb7  0.0s
 => => naming to docker.io/library/custom-httpd:latest