Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

docker

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
like image 505
tushar_ecmc Avatar asked Sep 16 '25 04:09

tushar_ecmc


1 Answers

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”]
like image 185
Ivan Kaloyanov Avatar answered Sep 18 '25 17:09

Ivan Kaloyanov