Hi there.
I am currently getting into the Docker Topic and got stuck while trying to reproduce the steps from the Dockerfile form this Tutuorial on Amazon Web Services
I have already gone through the steps and at the end it worked for me when I ran the Dockfile. But since I am trying to learn to get more into the topic I wanted to reproduce every single line from the dockerfile.
So, again… here is the content of the Dockerfile:
[ec2-user ecs-demo-php-simple-app]$ cat Dockerfile
FROM ubuntu:12.04
# Install dependencies
RUN apt-get update -y
RUN apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mcrypt php5-mysql
# Install app
RUN rm -rf /var/www/*
ADD src /var/www
# Configure apache
RUN a2enmod rewrite
RUN chown -R www-data:www-data /var/www
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
EXPOSE 80
CMD ["/usr/sbin/apache2", "-D", "FOREGROUND"]
and here is what I have tried to get to the same result:
$ Docker pull Ubuntu:latest
$ Docker run –i –t –d Ubuntu
$ docker exec CONTAINER-ID apt-get update –y
$ docker exec CONTAINER apt-get install -y git curl apache2 php5 libapache2-mod-php5 php5-mysql
$ docker exec CONTAINER rm -rf /var/www/*
#For the next step I cd'ed on my local machine into the folder I downloaded from the hub in the tutorial
$ docker cp src CONTAINER-ID :/var/www
$ docker exec CONTAINER-ID a2enmod rewrite
$ docker exec CONTAINER-ID bash -c "cat /etc/apache2/apache2.conf"
# and just for testing
$ docker exec CONTAINER-ID bash -c "curl http://localhost" docker exec
$ docker exec CONTAINER-ID netstat -tulpn | grep :80
At the end, the server seemed to be up and the port 80 was open.
However, I couldn’t reach the searcher via my web browser like I could when I ran the original Dockerfile.
I am running the toolbox on Win10 x64
I think that there is a problem with mapping the ports from the container and the VM what do you think?
I saved the container and tried to run it with
docker run -d -p 2376:80 apache/php /usr/sbin/apache2ctl -D FOREGROUND
since 2376 was the port from my VM. I also tried 9999 instead for the localhost.
Can anyone help me solving this problem?
EDIT :
By starting the container with
docker run -d -p 80:80 apache/php /usr/sbin/apache2ctl -D FOREGROUND
I can now reach the default APAChE2 page. However, in previous steps it should have replaced the index.html with the index.php from the tut right?