更新时间:2022-10-17 21:48:51
Linux服务状态显示为:
●docker.service - Docker应用程序容器引擎
加载:已加载(/lib/systemd/system/docker.service; enabled;供应商预设:启用)
活动:活动(运行)从星期一至星期三13:39:44 CST; 2min 24s ago
文件:http://docs.docker.com
主PID:672(docker)
内存:11.2M
CPU:62ms
CGroup: /system.slice/docker.service
└─672/ usr / bin / docker -d -H fd://
这解决了这个问题:
service docker restart
我不知道为什么。现在服务响应:
> curl -D - http://127.0.0.1:8080
HTTP / 1.1 200 OK
Hello world
此外,选项 - 公开8080
不需要这个工作。
编辑:
Required-Start:$ network
或某些东西。 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:
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2016-03-07 13:39:44 CST; 2min 24s ago
Docs: http://docs.docker.com
Main PID: 672 (docker)
Memory: 11.2M
CPU: 62ms
CGroup: /system.slice/docker.service
└─672 /usr/bin/docker -d -H fd://
This fixed the issue:
service docker restart
I don't know why. Now the service responds:
>curl -D - http://127.0.0.1:8080
HTTP/1.1 200 OK
Hello world
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.