How to access the root var/www/ directory of a Docker container via the host browser?

Asked

Viewed 256 times

1

I’m starting on Docker.

I created an image with the following command

docker run -ti -p 80:80 my-image

This image is a Ubuntu:14.04 where I installed apache and php5. I checked the root /var/www and the index page is there and php tbm installed php -v.

My host is Ubuntu 16.04. I’ve checked Docker’s IP through ifconfig and I have docker0 inet addr:172.17.0.1.

Using my host’s browser I do 172.17.0.1:80 and have the message "The Connection was reset".

I was hoping to see the apache homepage.

How to solve this?

  • 172.17.0.1 must be the IP of the Docker machine, no? See the container’s IP with docker inspect <seu_container> | awk '/IPAddress/ || /HostPort/', or just docker inspect <seu_container> and look for IPAddress

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.