docker-nginx: Port 80 and Port 443 not accessible when published via `ports`
Hi,
I’ve been trying unsuccessfully to redirect calls to http://localhost and https://localhost to a docker container by using nginx listening on port 80 and 443 inside its own docker container, with ports published via docker-compose.yml, i.e:
image: nginx:alpine
ports:
- 127.0.0.1:80:80
- 127.0.0.1:443:443
I cannot get this to work. I get connection refused. When I change the ports (on the host) to anything else (441, 81, 8443, 8080, …), everything works just fine. I’m not positive this is an nginx issue, but considering nginx image exposes port 80/443, I was wondering if there is some conflict.
I’ve checked to see that port 80 and 443 are not in use, and they aren’t, except for docker itself because of the above docker-compose.yml config. I’ve also checked pf filter rules – nothing in there that would forward traffic on port 80/443 to some other ip:port.
Any ideas?
ETA:
I’m on macOS Sierra. I’m using docker 1.12.5, docker-compose 1.9.0, docker-machine 0.8.2.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 10
- Comments: 18
same here.
@ian-axelrod Just to be sure, you did try:
correct? This works for me.
same situation here with
This is driving me crazy.
I went as far as tcpdumping the interface, but the log doesn’t really help. basically there’s an initial burst of traffic to localhost:http and some randomly allocated port, but then silence. With port 81 (xfer), there’s that same burst of traffic, but then a flurry of new requests between localhost:xfer and a few randomly assigned ports (sockets). Basically tcp handshakes then sequence increments. Happens with safari, too. Makes me think there’s something in the kernel itself that is causing this, or something else very low level even though system logs suggest nothing is amiss.
This is very frustrating.
It appears to happen for /any/ docker container that has a service listening on port 80 (host), not only nginx, so I suppose that this ticket should be transferred to docker for mac.
Yes, I’m sure.
Forgot to say I’m on docker for mac, so no virtualbox / docker-machine.
Also, I’ve tried having it listen on
0.0.0.0instead of localhost. That didn’t help.Works fine here:
(while in the other terminal):
Versions: