0

After creating container, I check with sudo docker ps and it shows like the following image.

docker ps result

Then I check with sudo docker ps -a and it shows it exited 36 seconds ago.

This is the code of my Dockerfile:

FROM ubuntu:14.04
MAINTAINER srini <srinivasanacg@gmail.com>
RUN apt-get update
RUN apt-get install -y apache2
RUN mkdir /var/lock/apache2
ENV APACHE_RUN_USER www_data
ENV APACHE_RUN_GROUP www_data
ENV APACHE_PID_FILE /var/run/apache2.pid
ENV APACHE_RUN_DIR /var/run/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_LOG_DIR /var/log/apache2
ENV LANG C
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
EXPOSE 80

2 Answers 2

2

You have to first debug the container like this way. Dokckerfile

FROM ubuntu:14.04 
MAINTAINER srini 
RUN apt-get update RUN apt-get install -y apache2 
RUN mkdir /var/lock/apache2 
ADD ./entry.sh /var/lock/apache2
ENV APACHE_RUN_USER www_data 
ENV APACHE_RUN_GROUP www_data 
ENV APACHE_PID_FILE /var/run/apache2.pid 
ENV APACHE_RUN_DIR /var/run/apache2 
ENV APACHE_LOCK_DIR /var/lock/apache2 
ENV APACHE_LOG_DIR /var/log/apache2 
#ENV LANG C CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"] EXPOSE 80
ENTRYPOINT ["/bin/bash", "entry.sh" ]

Now entry.sh

touch /var/lock/apache2/1.txt
tail -f /var/lock/apache2/1.txt

Start your container like this:

docker run -it --name $container_name -d $image_name

Now go inside your container like this :

docker exec -it $container_name bash

Manually start apache2 like this :

/usr/sbin/apache2 -D

And analyze the things where it is creating issue,check the logs and according to the analysis correct the Dockerfile steps.

Hope this help! Thank you!

2
  • It shows "Error response from daemon: Container e4f6f7353732526080d6507687d0707dd62e806c38d9265e8e49832cef80d82c is not running" May 31, 2017 at 5:28
  • first docker stop $container_name than docker rm -v $container_name after that follow the steps provided by me. May 31, 2017 at 5:29
0

The APACHE_RUN_USER/APACHE_RUN_GROUP environment variables are incorrect. The user should be: www-data

➜  docker logs apache
AH00543: apache2: bad user name www_data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.