Write a Docker File task marked failed

Hi @Inderpreet @Ayman @kodekloud-support3,

Can some please reply to what is wrong with my Dockerfile? I have exposed the port 5000 on the Dockerfile is asked from the task. Please.

The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. It does not configure Apache2 to run under such port.
You have to change port in apache2 config eg.
sed -i ‘s/80/5000/’ /etc/apache2/ports.conf

1 Like

Thanks, I really appreciate it.

Do not forget to start apache2 :slight_smile: this is as well missing

Sure, will do @andrzej:sweat_smile:

@Ayman @Inderpreet

can you take a look why my configuration failed?

image

/opt/docker/Dockerfile

FROM ubuntu
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y
RUN apt-get install apache2 -y
RUN sed -i ‘s/80/3003/’ /etc/apache2/ports.conf
EXPOSE 3003

ENTRYPOINT [“/usr/sbin/apache2ctl”]
CMD [“-D”,“FOREGROUND”,“-k”,“start”]

Have you tested with curl command?

Because in your dockerfile double quotes is not okay. A few is a block quotes.

curl command shows good

https://www.reddit.com/r/docker/comments/9wn5gw/be_aware_of_the_quotes_in_your_dockerfile/

this link said single quote not ok, has to be double quote for avoiding debugging nightmare :frowning:

I am not again double quotes, In your mention dockerfile a few double quotes looks like block quotes.

I have enrolled @mmumshad several course on Udemy, except the docker course, but from the course detail, no docker file section. :frowning: in the Kubernetes course, he briefly touched on docker. Anyone point me to where can i get some info for dockerfile format?

@Tej-Singh-Rana thank you for your help. just lately a little frustrated on failing tasks and unsure the reason. and didn’t find out what went wrong. I was sure that I solve the problems then submit, but FAILED jumped at you, don’t feel good. :slightly_frowning_face:

for the action RUN sed -i ‘s/80/3003/’ /etc/apache2/ports.conf I guess that you have to install sed, I’m not sure

And now I’m sure
Step 5/8 : RUN sed -i ‘s/80/3003/’ /etc/apache2/ports.conf
—> Running in 9d6411dab3f1
sed: -e expression #1, char 1: unknown command: `�’
The command ‘/bin/sh -c sed -i ‘s/80/3003/’ /etc/apache2/ports.conf’ returned a non-zero code: 1

1 Like

First: remove EXPOSE 3003
Second: sed command is not correct

@Jenna, the best place where you can learn about dockerfile is in the official docs Dockerfile reference | Docker Docs
You can read/hear/see another materials, and I truly encourage you to do so, but to have a deeper understanding you need to go to the sources.

thank you @francilio

what is the correct sed command?

The syntax is sed -i ‘s/pattern/replace/g’ /ec/apache2/ports.conf