这是Dan Low提供的答案的补充。
配置Docker守护程序端口有两种方法:
在 / etc / default / docker 文件中配置:
DOCKER_OPTS="-H tcp://127.0.0.1:5000 -H unix:///var/run/docker.sock"
在 /etc/docker/daemon.json中 配置:
{“debug”: true,
“hosts”: [“tcp://127.0.0.1:5000”, “unix:///var/run/docker.sock”]
}
配置端口后,重新启动Docker服务。
如果未配置Docker默认套接字,则可能会出现问题中提到的类似问题,即 Docker将等待无限期 。
注意:但不要同时在 两个 配置文件中进行配置。可能会发生以下错误:
Waiting for /var/run/docker.sockunable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: hosts: (from flag: [tcp://127.0.0.1:5000 unix:///var/run/docker.sock], from file: tcp://127.0.0.1:5000)
其原因将两个的 用户端口[TCP://127.0.0.1:5000] 和
默认多克尔插座[UNIX:///var/run/docker.sock] 是用户端口使得接入到 多克尔的API
而默认套接字启用CLI。如果
/etc/default/docker文件中未提及默认端口[unix:///var/run/docker.sock],则可能会发生以下错误:
# docker psCannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
该错误不是因为Docker容器未运行,而是因为未启用默认Docker套接字。
这适用于Docker 17.04版本,并且可能因不同版本的Docker而有所不同。



