Write a Docker file - failed

@mmumshad @Inderpreet @andrzej @Tej-Singh-Rana
any idea what have gone wrong with my task? its complaining about the required port is not configured to be used by apache2, but I did configured that and the image is build succesfully and I was able to run the image as well. here is the log shows everything:



As per the question below:
create a docker file /opt/docker/Dockerfile (please keep D capital of Dockerfile) on App server 1 in Stratos DC and configure to build an image with the following requirements:
a. Use ubuntu as the base image.
b. Install apache2 and configure it to work on 6400 port. (do not update any other Apache configuration settings like document root etc).

Hello nashwan,
Have you created container from this image? to cross verify. Is it running?

Hello @player001,
yes, as per the second screenshoot, I am able to run the container I built. I think that is a clear verification the container is build and running all good.

You have to try with -p flag to assign port. After that curl to get access of apache.

I havent tried that to be honest, but as per the requirement of the question, I would assume we are just suppose to manage to build docker image successfully with the requirements they asked for. didn’t even run docker inspect since I was pretty sure what I have done is built with success and I am able to run the container from the image I built.

where is the questions asked me to run the container by the way? otherwise I know if I am suppose to run the container to access to apache I would have to run with -p
create a docker file /opt/docker/Dockerfile (please keep D capital of Dockerfile) on App server 1 in Stratos DC and configure to build an image with the following requirements:
a. Use ubuntu as the base image.
b. Install apache2 and configure it to work on 6400 port. (do not update any other Apache configuration settings like document root etc).

@nashwan did you modify /etc/apache2/sites-available/000-default.conf as well?

as it cleared form your Dockerfile, the sed command is wrong. Also, in this task , EXPOSE 6400 is not required. After building the image, run the following:
docker run -p hostport:6400 --name=container_name built_image_name

@francilio no I havent modified that file. not sure why that would be required, its saying don’t update any apache configuration files, so I didnt.

@Devops
1- it says install and configure Apache to work on port 6400, sed sounds to be a requirement thing there.
2- it never says run the container with specific port or at least run the container, the question is clearly asking you to build the the image with these settings. if that is the case, then the question is misleading!

@nashwan the first 3 lines on ports.conf are:

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

So it is required to change /etc/apache2/sites-available/000-default.conf (the one in sites-enabled is just a symlink to this one) to correctly configure the port.

  • Yes, sed is required but the syntax is not correct which result in getting the error message "apache port is not configured to use port 6400’.

  • Again, delete EXPOSE 6400 from Dockerfile and correct the sed like: sed -i ‘/s/pattern/replace/g’ /etc/apache2/ports.conf. Build the image and then run a container for testing, and you will access apache from localhost as: curl http://localhost:host_port/.

  • Below is my dashboard

@Devops and @francilio thank you very much for the explanation.

@Inderpreet @rahul456 Hello Team, I did a Task on write a docker file but it seemed to fail during validation

I tried to retake the task but couldn’t as task shows failed

kindly assist.