This is my Dockerfile
contents:
from ubuntu:latest
#ARG DEBIAN_FRONTEND=noninteractive
COPY entrypoint.sh /sbin/entrypoint.sh
COPY info.php /var/www/html/
ENV TZ=Asia/Tehran
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get upgrade -y && apt-get install apache2 php -y
ENV APACHE_CONF_DIR=/etc/apache2
RUN chmod 755 /sbin/entrypoint.sh
CMD ['/sbin/entrypoint.sh']
And this is my entrypoint.sh
contents:
#!/bin/bash
source /etc/apache2/envvars
exec apache2 -D FOREGROUND
Image makes fine with no issue, and it also starts without any issues, but the file entrypoint.sh
does not start. When I exec -it
into the container and run this file manually, apache2
works fine and my info.php
is accessible through the web.
I create container with this command (to make it running):
docker run -dp80:80 -v /logs:/var/log a2 bash
Then I go to the container docker exec -it NAME
, then run /sbin/entrypoint.sh
and I see there's no problem.
I create another container docker run -dp81:80 a2
, but my file does not run. When I use docker run -dp81:80 a2 /sbin/entrypoint.sh
, then my file runs and my info.php
is show in the internet browser.
Would you please help me where is my issue that without using my file name at the end of command, container does exit immediately after started?