Docker Community Forums

Share and learn in the Docker community.

Can't restart my container "httpd (pid 8) already running"



I just made my own image (webserver with apache2 & php7), but something goes wrong.
When run my container from my image, all is OK, but when i try to “docker restart” it, the status goes to exited.

Docker logs :

-> docker logs 1936e2b122b5
httpd (pid 8) already running

i tryied to delete the pid file in /var/run/ and the restarts works; but just 1time.
Do you have a solution to delete this pid file at stop or start automatically when i do a “docker restart” ?

i tryied to put some things in my dockerfile but nothing works…

Thanks for help !

My dockerfile : 

    FROM debian:jessie
RUN apt-get update \
&& apt-get install -y apache2 \
&& echo "deb jessie all" > /etc/apt/sources.list.d/dotdeb.list \
&& apt-get install -y wget \
&& wget \
&& apt-key add dotdeb.gpg \
&& apt-get update \
&& apt-get install -y php7.0 php7.0-fpm \
&& apt-get install -y libapache2-mod-php7.0

ADD host-apache2.conf /etc/apache2/site-enabled/000-default.conf
ADD index.html /var/www/html/index.html

CMD /usr/sbin/apache2ctl -D FOREGROUND

(Tekki) #2

Take a look at CMD in the official httpd Dockerfile and at httpd-foreground. You have to move such commands into a script file because they have to run every time the container starts.