docker相关报错

docker
珍惜每一个错误

docker命令自动补全

1
yum install -y bash-completion

使用的镜像加速/etc/docker/daemon.json文件格式不规范导致docker服务启动报错

错误原因:

使用镜像加速,配置了/etc/docker/daemon.json文件,在配置该文件时没有符合json格式规范。

错误现象:

1
2
[root@localhost ~]# systemctl restart docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[root@localhost ~]# systemctl status docker.service
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since 五 2019-04-19 01:03:25 CST; 6s ago
Docs: https://docs.docker.com
Process: 1169 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 1169 (code=exited, status=1/FAILURE)

4月 19 01:03:23 localhost.localdomain systemd[1]: docker.service: main process exited, code=exi...URE
4月 19 01:03:23 localhost.localdomain systemd[1]: Failed to start Docker Application Container ...ne.
4月 19 01:03:23 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
4月 19 01:03:23 localhost.localdomain systemd[1]: docker.service failed.
4月 19 01:03:25 localhost.localdomain systemd[1]: docker.service holdoff time over, scheduling ...rt.
4月 19 01:03:25 localhost.localdomain systemd[1]: start request repeated too quickly for docker...ice
4月 19 01:03:25 localhost.localdomain systemd[1]: Failed to start Docker Application Container ...ne.
4月 19 01:03:25 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
4月 19 01:03:25 localhost.localdomain systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
1
2
[root@localhost ~]# dockerd
unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character 's' looking for beginning of value
1
2
3
4
5
6
7
8
9
10
[root@localhost ~]# docker version
Client:
Version: 18.09.4
API version: 1.39
Go version: go1.10.8
Git commit: d14af54266
Built: Wed Mar 27 18:34:51 2019
OS/Arch: linux/amd64
Experimental: false
error during connect: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/version: read unix @->/var/run/docker.sock: read: connection reset by peer

解决方法:

检查该json文件确保符合json格式规范,然后执行systemctl daemon-reload后,启动docker服务。

docker push镜像到私有仓库时报错

错误原因:

可能是由于客户端采用https,docker registry未采用https服务所致

错误现象:

1
2
3
[root@localhost ~]# docker push 192.168.163.132:5000/ubuntu:18.04
The push refers to repository [192.168.163.132:5000/ubuntu]
Get https://192.168.163.132:5000/v2/: http: server gave HTTP response to HTTPS client

解决方法:

在/etc/docker/daemon.json中添加私有仓库的IP,然后执行systemctl daemon-reload后,启动docker服务。

1
{"insecure-registries": ["192.168.163.132:5000"]}

注意:在/etc/docker/daemon.json文件中json的格式
json