Docker在安装时遇到的问题(第一部分)

一、在用docker-config-manager安装yum源时出现错误

[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
Could not fetch/save url https://download.docker.com/linux/centos/docker-ce.repo to file /etc/yum.repos.d/docker-ce.repo: [Errno 14] curl#35 - "TCP connection reset by peer"

原因:是因为官网镜像无法使用的原因,所以我们要将官网源更换成aliyun的镜像源


[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
已加载插件:fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# ls /etc/yum.repos.d/
.... docker-ce.repo

二、docker pull centos无法访问docker官方镜像

问题:

[root@localhost ~]# docker search centos
Error response from daemon: Get "https://index.docker.io/v1/search?q=centos&n=25": dial tcp 162.125.2.3:443: c               onnect: connection refused

解决:

[root@localhost ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": [
        "https://docker.dark-nt.us.kg"
  ]
}


[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemclt restart docker

[root@localhost ~]# docker pull centos:centos7
centos7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4
Status: Downloaded newer image for centos:centos7
docker.io/library/centos:centos7

三、在daemon.json配置问题

问题:

[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.

一般出现这个问题大概率是配置文件出现了错误,而我只改了daemon.json所以要先排查

解决:后来发现是我的格式出现了问题,要加逗号隔离并且在同一个大括号中 


[root@localhost ~]# vim /etc/docker/daemon.json

{
"registry-mirrors": ["https://docker.dark-nt.us.kg"],

"hosts": ["tcp://0.0.0.0:2375","unix:///var/run/docker.sock"]

}


[root@localhost ~]# ss -anput | grep ":2375"
tcp    LISTEN     0      128      :::2375                 :::*                   users:(("dockerd",pid=27958,fd=4))

 

你可能感兴趣的:(运维-Docker,docker,容器,运维)