解决docker无法启动的问题

时间:2025-04-13 20:20:15

由于下载jenkins出现问题TLS handshark timeout,用了网上的一个方法:

$ echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=\"" | sudo tee -a /etc/default/docker

导致docker无法启动

sudo service docker restart
Job for  failed because the control process exited with error code. See "systemctl status " and "journalctl -xe" for details.
root@zhangyuan7-Lenovo-XiaoXin-700-15ISK:/etc/docker# systemctl status 
●  - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since 四 2018-04-26 14:23:53 CST; 1min 23s ago
     Docs: 
  Process: 5210 ExecStart=/usr/bin/dockerd -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE)
 Main PID: 5210 (code=exited, status=1/FAILURE)

426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]:       --tlskey string                         Path to TLS key file (default "/root/.docker/")
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]:       --tlsverify                             Use TLS and verify the remote
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]:       --userland-proxy                        Use userland proxy for loopback traffic (default true)
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]:       --userland-proxy-path string            Path to the userland proxy binary
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]:       --userns-remap string                   User/Group setting for user namespaces
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK systemd[1]: Failed to start Docker Application Container Engine.
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]:   -v, --version                               Print version information and quit
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK dockerd[5210]: Run 'dockerd COMMAND --help' for more information on a command.
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK systemd[1]: : Unit entered failed state.
426 14:23:53 zhangyuan7-Lenovo-XiaoXin-700-15ISK systemd[1]: : Failed with result 'exit-code'.

查阅了网上好多方法,都不对症,好吧,只有对比能用的服务器上面的docker配置看看有什么问题,终于在/etc/default/中的docker文件,需要把文件中的最后一行注释掉

# Here in Debian, this file is sourced by:
#   - /etc//docker (sysvinit)
#   - /etc/init/docker (upstart)
#   - systemd's 

# Use of this file for configuring your Docker daemon is discouraged.

# The recommended alternative is "/etc/docker/", as described in:
#   /v1.11/engine/reference/commandline/daemon/#daemon-configuration-file

# If that does not suit your needs, try a systemd drop-in file, as described in:
#   /v1.11/engine/admin/systemd/#custom-docker-daemon-options
#DOCKER_OPTS="$DOCKER_OPTS --registry-mirror="

然后重启 sudo service docker restart
终于可以了!!你大爷的