docker后,啟動時報錯

yum安裝docker后,啟動時報錯,systemctl status docker信息如下

[root@localhost ~]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 三 2018-01-17 15:10:45 CST; 13s ago
     Docs: https://docs.docker.com
  Process: 2800 ExecStart=/usr/bin/docker daemon --registry-mirror=https://*prk4fun.mirror.aliyuncs.com --registry-mirror=https://*prk4fun.mirror.aliyuncs.com (code=exited, status=125)
 Main PID: 2800 (code=exited, status=125)

1月 17 15:10:45 localhost.localdomain docker[2800]: tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
1月 17 15:10:45 localhost.localdomain docker[2800]: top         Display the running processes of a container
1月 17 15:10:45 localhost.localdomain docker[2800]: unpause     Unpause all processes within one or more containers
1月 17 15:10:45 localhost.localdomain docker[2800]: update      Update configuration of one or more containers
1月 17 15:10:45 localhost.localdomain docker[2800]: version     Show the Docker version information
1月 17 15:10:45 localhost.localdomain docker[2800]: wait        Block until one or more containers stop, then print their exit codes
1月 17 15:10:45 localhost.localdomain docker[2800]: Run 'docker COMMAND --help' for more information on a command.
1月 17 15:10:45 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
1月 17 15:10:45 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
1月 17 15:10:45 localhost.localdomain systemd[1]: docker.service failed.


  • 很奇怪的是這一行
Process: 2800 ExecStart=/usr/bin/docker daemon --registry-mirror=https://*prk4fun.mirror.aliyuncs.com 
--registry-mirror=https://*prk4fun.mirror.aliyuncs.com (code=exited, status=125)

兩個--registry-mirror,知道是什么鬼。這個鏡像的地址是阿里云加速的地址,回想安裝的步驟。

使用腳本自動安裝
在測試或開發(fā)環(huán)境中 Docker 官方為了簡化安裝流程,提供了一套便捷的安裝腳本,CentOS 系統(tǒng)上可以使用這套腳本安裝:

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

以為是加了Aliyun的問題,重新卸載,再安裝問題依舊。

  • 找到/etc/systemd/system/docker.service文件,查看文件內(nèi)容,發(fā)現(xiàn)文件內(nèi)容被修改過

原來的ExecStart被注釋掉了,加了daemon,配置上了aliyun的加速器地址

# 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
#ExecStart=/usr/bin/dockerd
ExecStart=/usr/bin/docker daemon --registry-mirror=https://*prk4fun.mirror.aliyuncs.com 
--registry-mirror=https://*prk4fun.mirror.aliyuncs.com
  • 修改一下這個文件,把daemon這一行注釋掉,放開原來的注釋。docker啟動正常。
[root@localhost docker]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2018-01-17 15:31:34 CST; 25min ago
     Docs: https://docs.docker.com
 Main PID: 3275 (dockerd)
   Memory: 45.3M
   CGroup: /system.slice/docker.service
           ├─3275 /usr/bin/dockerd
           └─3289 docker-containerd --config /var/run/docker/containerd/containerd.toml
  • 加速器配置

針對Docker客戶端版本大于1.10.0的用戶
您可以通過修改daemon配置文件/etc/docker/daemon.json來使用加速器:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://*******.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容