I've built a docker file, and the container exits immediately while I'm building and running it.
Docker is installed on Ubuntu 18.04, which is my basic operating system.
The following are the contents of my Dockerfile:
FROM ubuntu <br>
RUN apt-get update <br>
RUN apt-get install apache2 -y <br>
RUN apt-get install apache2-utils -y <br>
RUN apt-get clean <br>
RUN rm -rf /var/lib/apt/lists/* <br>
EXPOSE 80 <br>
ENTRYPOINT ["apache2ctl"] <br>
CMD ["/usr/sbin/apache2ctl", "-DFOREGROUND"] <br>
My command for building image
sudo docker build -t myimage
My command for running the container
sudo docker run -it -p 80:80 myimage
My output
sudo docker ps -a <br>
CONTAINER ID IMAGE COMMAND
CREATED STATUS PORTS
NAMES 6b1891ac8195 myimage "apache2ctl /usr/sbi…"
15 minutes ago Exited (1) 15 minutes ago
infallible_williamson
dc3cc1328508 5b5570dec3a9
"tail -f /dev/null /…" 17 minutes ago Exited (1) 17 minutes ago stoic_ganguly
a67f5cb9f080 53a1c1ddc4fc "tail -f /dev/null /…" 18 minutes ago Exited (1) 18 minutes ago
vibrant_grothendieck
07fa216c6c00 b5d19c3240f7
"apache2ctl /usr/sbi…" 31 minutes ago Exited (1) 31 minutes ago keen_blackburn
71d686cb0b8e 568c96482f1c
"apache2ctl /bin/sh …" 39 minutes ago Exited (1) 38 minutes ago happy_saha
11e0abe7c2ec d056b6f1d824 "apache2ctl /bin/sh …" 40 minutes ago Exited (1) 40 minutes ago
vibrant_kare
17ed24e8eef4 d056b6f1d824 "apache2ctl /bin/sh …" 3 hours ago Exited (1) 3 hours ago
gallant_dijkstra
b1c6d9bf2765 d056b6f1d824
"apache2ctl /bin/sh …" 3 hours ago Exited (1) 3 hours ago
elated_joliot
Help please