docker學習-配置錯誤的源
問題點剖析
使用docker安裝了nginx,編寫Dockerfile,映射端口,終於跑起來了。但是,當我重啟服務器,再次查看docker容器的狀態,發現報錯了。
# docker ps -a
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
然后重啟docker
# sudo service docker start
Redirecting to /bin/systemctl start docker.service
Job for docker.service failed because start of the service was attempted too often. See "systemctl status docker.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed docker.service" followed by "systemctl start docker.service" again.
發現還是不行,根據提示查看docker.service的status
# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since 二 2020-05-05 01:13:34 CST; 9s ago
Docs: https://docs.docker.com
Process: 1880 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 1880 (code=exited, status=1/FAILURE)
5月 05 01:13:32 10.0.2.8 systemd[1]: docker.service: main process exited, code=exited, sta...URE
5月 05 01:13:32 10.0.2.8 systemd[1]: Failed to start Docker Application Container Engine.
5月 05 01:13:32 10.0.2.8 systemd[1]: Unit docker.service entered failed state.
5月 05 01:13:32 10.0.2.8 systemd[1]: docker.service failed.
5月 05 01:13:34 10.0.2.8 systemd[1]: docker.service holdoff time over, scheduling restart.
5月 05 01:13:34 10.0.2.8 systemd[1]: Stopped Docker Application Container Engine.
5月 05 01:13:34 10.0.2.8 systemd[1]: start request repeated too quickly for docker.service
5月 05 01:13:34 10.0.2.8 systemd[1]: Failed to start Docker Application Container Engine.
5月 05 01:13:34 10.0.2.8 systemd[1]: Unit docker.service entered failed state.
5月 05 01:13:34 10.0.2.8 systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
分析發現原因是docker不能啟動
Failed to start Docker Application Container Engine.
daemon.json如果包含格式不正確的JSON,Docker將無法啟動
檢查了一下daemon.json,果真,少了一個“。
修改daemon.json,然后重啟解決了。
參考
【docker安裝完了以后,服務啟動不了】http://www.docker.org.cn/thread/72.html
