docker服务启动将在Debian上永久激活

docker服务启动将在Debian上永久激活,docker,debian,virtual-machine,Docker,Debian,Virtual Machine,我尝试在我的debian vm上设置docker。在弄清楚如何让docker读取默认的/docker文件后,我遇到了一个问题,它是从哪里开始的,实际上是在我配置的端口上。但它还没有完成启动过程 操作系统详细信息: PRETTY_NAME="Debian GNU/Linux 9 (stretch)" NAME="Debian GNU/Linux" VERSION_ID="9" VERSION="9 (stretch)" ID=debian HOME_URL="https://www.debian.

我尝试在我的debian vm上设置docker。在弄清楚如何让docker读取默认的/docker文件后,我遇到了一个问题,它是从哪里开始的,实际上是在我配置的端口上。但它还没有完成启动过程

操作系统详细信息

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
DOCKER_OPTS="-H tcp://127.0.0.1:2375"
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker -d $DOCKER_OPTS -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
/etc/default/docker

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
DOCKER_OPTS="-H tcp://127.0.0.1:2375"
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker -d $DOCKER_OPTS -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
docker.service

PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
DOCKER_OPTS="-H tcp://127.0.0.1:2375"
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker -d $DOCKER_OPTS -H fd://
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
服务装卸工状态

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: activating (start) since Tue 2017-08-29 13:51:04 CEST; 15min ago
     Docs: https://docs.docker.com
 Main PID: 883 (docker)
    Tasks: 3 (limit: 4915)
   Memory: 4.2M
      CPU: 10ms
   CGroup: /system.slice/docker.service
           └─883 /usr/bin/docker -d -H tcp://127.0.0.1:2375 -H fd://

正如您所看到的,它现在正在运行15分钟,我不知道这里的问题是什么。

Docker的侦听套接字(Docker的)或连接套接字(Docker cli)具有类似URL的语法。这些都是完全没有文件记录的,而且往往具有误导性。例如,
fd://
不监听/连接文件描述符,而是使用静态套接字。在我的回答中,我试图通过分析docker cli源代码来收集参考列表


我还发现dockerd中默认的
fd://
设置存在类似的问题。我的结果和这里的问题评论/聊天日志都表明,通过指定的TCP端口(理想情况下,
tcp://127.0.0.1:2375
)解决了问题。

关闭服务并运行
sudo dockerd-Htcp://127.0.0.1:2375 -H fd://
在终端中,查看它是否工作
警告[0000][!]不设置就不要绑定任何IP地址--tls如果您不知道自己在做什么,请验证[!]通过套接字激活未找到套接字:确保服务是由systemd启动的
Use
sudo dockerd-Htcp://127.0.0.1:2375
取而代之的是,它最终会起作用!谢谢我试图从
docker.service
文件中删除
-H fd://
,但看起来他从未保留过它。在我的例子中,我在/var/lib/docker中有一些以前安装的剩余内容。我停止了该服务,卸载了docker,删除了该文件夹,安装了docker,它正常工作。下次无法测试它。如果有人认为这是一个有效的解决方案,请告诉我,我可以将其标记为答案