Difference between revisions of "Docker on Mac"

From BITPlan Wiki
Jump to navigation Jump to search
(Created page with "Unfortunately Docker usage on mac is limited see: * https://docs.docker.com/docker-for-mac/networking <source lang='bash'> docker run -d -p 80:80 --name webserver nginx </sou...")
 
Line 1: Line 1:
 
Unfortunately Docker usage on mac is  limited see:
 
Unfortunately Docker usage on mac is  limited see:
 
* https://docs.docker.com/docker-for-mac/networking
 
* https://docs.docker.com/docker-for-mac/networking
 +
This means the approach:
 +
<source lang='bash'>
 +
docker run -d  --name webserver nginx
 +
docker inspect webserver | grep 'IPAddress":'
 +
            "IPAddress": "172.17.0.2",
 +
                    "IPAddress": "172.17.0.2",
 +
</source>
 +
and then trying to connect via http://172.17.0.2 on port 80 won't work
 +
The workaround is to publish the port locally:
 
<source lang='bash'>
 
<source lang='bash'>
 
docker run -d -p 80:80 --name webserver nginx
 
docker run -d -p 80:80 --name webserver nginx
 
</source>
 
</source>
 +
http://localhost now works

Revision as of 15:46, 27 August 2017

Unfortunately Docker usage on mac is limited see:

This means the approach:

docker run -d  --name webserver nginx
docker inspect webserver | grep 'IPAddress":' 
            "IPAddress": "172.17.0.2",
                    "IPAddress": "172.17.0.2",

and then trying to connect via http://172.17.0.2 on port 80 won't work The workaround is to publish the port locally:

docker run -d -p 80:80 --name webserver nginx

http://localhost now works