Docker 无法配置为服务。
安装 docker 后,没有任何 docker 命令响应,例如 docker info 或 docker version。
从包中安装了 docker ce 及其组件。
sudo dpkg -i containerd.io_1.2.4-1
docker-ce_18.09.9~3-0~ubuntu-bionic_amd64.deb
docker-ce-cli_18.09.9~3-0~ubuntu-bionic_amd64.deb
其次是
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
docker.service 位于 /etc/systemd/system/multi-user.target.wants 下
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[Service]
Type=notify
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=1048576
TasksMax=infinity
Delegate=yes
KillMode=process
[Install]
WantedBy=multi-user.target
/etc/default/docker 内容:
export http_proxy="http://proxy.com:80/"
export https_proxy="http://proxy.com:80/"
export NO_PROXY="localhost,127.0.0.1,.example.com"
export no_proxy=$NO_PROXY
DOCKER_OPTS="--dns <dns server> --dns <dns server> -H tcp://0.0.0.0:4321 -H unix:///var/run/docker.sock --storage-driver=devicemapper --storage-opt dm.datadev=/dev/vg-docker/data
--storage-opt dm.metadatadev=/dev/vg-docker/metadata --storage-opt dm.basesize=100G"
检查状态时,它只是挂起并显示以下消息
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (start) since Mon 2021-04-26 08:48:55 PDT; 2min 2s ago
Docs: https://docs.docker.com
Main PID: 21021 (docker)
Tasks: 17
CGroup: /system.slice/docker.service
└─21021 /usr/bin/docker daemon --dns 171.40.110.110 --dns 171.40.110.111 -H tcp://0.0.0.0:4321 -H unix:///var/run/docker.sock --storage-driver=devicemapper -
systemd[1]: Starting Docker Application Container Engine...
操作系统:Ubuntu 18.04