tushar_ecmc
tushar_ecmc

Reputation: 188

How to fix the Dockerfile CMD error? As I am trying to create an apache server on ubuntu image

This is my Docker file

FROM ubuntu 
RUN apt-get update 
RUN apt-get install –y apache2 
RUN apt-get install –y apache2-utils 
RUN apt-get clean 
EXPOSE 80 CMD [“apache2ctl”, “-D”, “FOREGROUND”]

This is the error I get

Step 6/6 : EXPOSE 80 CMD ["apache2ct1","-D","FOREGROUND"]
Invalid containerPort: CMD

Upvotes: 4

Views: 1406

Answers (1)

Ivan Kaloyanov
Ivan Kaloyanov

Reputation: 1748

EXPOSE does not provide CMD itself, CMD is a separate parameter in Docker file syntax. With that been said your Dockerfile should be like this:

FROM ubuntu 
RUN apt-get update 
RUN apt-get install –y apache2 
RUN apt-get install –y apache2-utils 
RUN apt-get clean 
EXPOSE 80 
CMD [“apache2ctl”, “-D”, “FOREGROUND”]

Upvotes: 8

Related Questions