Cannot access apache on docker from my local host

I followed this beginner tutorial about docker , which basically instructs you to create an apache container and map the localhost port to the one on the container. when i try localhost: 80 it doesn't connect even though the container is up and running. I even made a rule in the firewall to allow connection to port 80, but could not connect to the local host.

Any ideas?

+5
source share
2 answers

On Windows / OS X, Docker runs inside a Linux virtual machine (Docker Toolbox) with a default IP address of 192.168.99.100. Thus, when you use docker run -p 80:80 to bind the container port to the host port, it actually binds to port 80 of the virtual machine. Thus, you need the address http://192.168.99.100 .

The address 172.17.0.3 is the address of the docker container inside , which is not directly accessible from Windows / OS X.

+6
source

Add a line to your DockerFile before restarting apache.

 RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf 
+2
source

Source: https://habr.com/ru/post/1246816/


All Articles