I want to run Jenkins, but to demonstrate the problem, I'm running a netcat server container in Ubuntu 15.10:
Docker version 1.6.2, build 7c8fca2
Here's my Dockerfile:
FROM ubuntu
CMD while true; do echo 'HTTP/1.1 200 OK\r\n\r\nHello world' | nc -l 8080; done
When run on the host, this one-liner will return HTTP 200 responses.
Now, on the container. Ran docker build -t mydoc .
. Ran docker run -it --expose 8080 -p 8080:8080 mydoc
. In another terminal, tried to curl it: curl -D - -o - http://127.0.0.1:8080
.
It just blocks with no response.
Some possibly relevant info:
>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1acc13bb3384 mydoc:latest "/bin/sh -c 'while t 48 seconds ago Up 47 seconds 0.0.0.0:8080->8080/tcp goofy_darwin
and
>netstat -ant | grep 8080
tcp 0 1 10.0.2.15:34512 172.17.0.25:8080 SYN_SENT
tcp 0 0 127.0.0.1:33276 127.0.0.1:8080 ESTABLISHED
tcp6 0 0 :::8080 :::* LISTEN
tcp6 78 0 127.0.0.1:8080 127.0.0.1:33276 ESTABLISHED
Note the SYN_SENT. That's as far as it gets.
The Linux service status showed as:
This fixed the issue:
I don't know why. Now the service responds:
Also, the option
--expose 8080
was not necessary for this to work.EDIT:
After getting 1.6.2 to work, I upgraded to 1.10.2 and haven't seen this problem yet. I suspect some kind of race condition on host startup, but can't say for sure. Maybe the docker service script needs a
Required-Start: $network
or something.