一、问题描述

1、docker login 私有仓库时报错

docker login 10.x.x.98
Username: admin
Password:
Error response from daemon: Get https://10.x.x.98/v2/: x509: cannot validate 
certificate for 10.x.x.98 because it doesn't contain any IP SANs

2、docker pull 私有仓库时报错

docker pull 10.x.x.98/library/maven:3.8.6-openjdk-11-master

Error response from daemon: Get "https://10.x.x.98/v2/": x509: cannot 
validate certificate for 10.x.x.98 because it doesn't contain any IP SANs

二、添加配置(两种方法不可同时使用)

方法一

1、在/etc/docker/daemon.json中添加私有仓库地址(如果没有daemon.json文件,自行创建

{
    "registry-mirrors": ["http://10.x.x.98"]
}

2、在/usr/lib/systemd/system/docker.service中添加私有仓库地址

vim  /usr/lib/systemd/system/docker.service

找到 [Service] ,再找到 ExecStart ,行末尾添加 --insecure-registry 私有仓库地址

[Service]
Type=notify
# 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 -H fd:// -H tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock --insecure-registry http://10.x.x.98
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

方法二

和方法1配置会有冲突,不可同时配置

{
    "registry-mirrors": ["http://10.x.x.x","http://10.x.x.x","http://10.x.x.x"],
    "insecure-registries": ["10.x.x.x:8080"]
}

三、重启docker

systemctl restart docker
Warning: docker.service changed on disk. Run 'systemctl daemon-reload' to reload units.

如果遇到以上问题,请按照提示步骤执行:

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




[root@localhost docker]# docker login http://10.82.26.121:18080/
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded




[root@localhost docker]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

四、测试 

[root@localhost docker]# docker pull 10.x.x.98/library/maven:3.8.6-openjdk-11-master
3.8.6-openjdk-11-master: Pulling from library/maven
001c52e26ad5: Already exists
d9d4b9b6e964: Already exists
2068746827ec: Already exists
9daef329d350: Already exists
d85151f15b66: Already exists
66223a710990: Already exists
db38d58ec8ab: Already exists
2896deaba78c: Already exists
25fd53091b07: Already exists
dd3ce32e87de: Already exists
d5c80bc7eb3c: Pull complete
Digest: sha256:e8e5a2b54cc5c390edef722790f4a4fba41dc6a08325951af2be11a27d2fcb58
Status: Downloaded newer image for 10.x.x.98/library/maven:3.8.6-openjdk-11-master
10.x.x.98/library/maven:3.8.6-openjdk-11-master

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐