Can't access docker container on port 80 on OSX Can't access docker container on port 80 on OSX nginx nginx

Can't access docker container on port 80 on OSX


if you are using docker-for-mac:

Accessing by localhost:80 is correct, though you still have to ensure you do not have a local apache/nginx service running. Often leftovers from boxen/homebrew exist binding that port, because thats what developers did back then :)

if you are using dockertoolbox/virtualbox/whatever hypervisor

You will not be able to access it by localhost, by by the docker-machine ip, so write docker-machine ip default and the use http://$ip:80 in your browser

if that does not help

Ensure your nginx container actually does work, so connect to the container: docker exec -i -t <containerid> bash

and then run ps aux nginx or if telnet is installed try to connect to localhost


Solved!

Problem was, that long long time ago I installed pow (super simple automated rails server which run application on app_name.local domain). And this beast left LaunchAgent script which update pf to forward port 80 to pow port.


In my current job we have development environment made with docker-compose.

A privilege to use.

[W]hen I try to access [nginx on port 80] for example via curl I get error.

Given there's nothing from causing you from accessing docker on your host os you should look at the app running inside the container to ensure it's binding to the correct host, e.g. 0.0.0.0 and not localhost.

For example, if you're running Nuxt inside a container with nuxt-ts observe Nuxt will default to localhost thereby causing the container not to connect to the docker network whereas npx nuxt-ts -H 0.0.0.0 gets things squared away with the container's internal server connecting to the ip of the docker network used (verify ip like docker container inspect d8af01990363).