问题描述

层级 时间 用户 事件
Information 2023/07/08 12:47:45 cxloge Add image from xx.xx.31.240:1923/go-gitea/gitea:1.19.3
Error 2023/07/08 12:47:48 cxloge Failed to pull image [Get "https://xx.xx.31.240:1923/v2/": http: server gave HTTP response to HTTPS client].

解决方法

通过ps -ef|grep docker获取配置dockerd --config-file的路径为/var/packages/ContainerManager/etc/dockerd.json

然后添加添加insecure-registries的http认证

cxloge@synocxloge:~$ ps -ef|grep docker
root      7780     1  0 Jul07 ?        00:00:00 /var/packages/ContainerManager/target/tool/docker_event_watcherd
root      7796     1  0 Jul07 ?        00:00:08 /var/packages/ContainerManager/target/usr/bin/dockerd --config-file /var/packages/ContainerManager/etc/dockerd.json
root      7848  7796  0 Jul07 ?        00:00:05 containerd --config /var/run/docker/containerd/containerd.toml --log-level info
cxloge   11662  9796  0 13:15 pts/0    00:00:00 grep --color=auto docker

# 备份 dockerd.json
cxloge@synocxloge:~$ sudo cp /var/packages/ContainerManager/etc/dockerd.json /var/packages/ContainerManager/etc/dockerd.json.bak

cxloge@synocxloge:~$ cd /var/packages/ContainerManager/etc/
cxloge@synocxloge:/var/packages/ContainerManager/etc$ ls -la
total 16
drwxr-xr-x 1 root root 112 Jul  8 13:30 .
drwxr-xr-x 1 root root 300 Jul  8 09:45 ..
drwxr-xr-x 1 root root   0 Jul  7 23:22 cert
-rw------- 1 root root 122 Jul  7 23:22 dockerd.json
-rw------- 1 root root 122 Jul  8 13:30 dockerd.json.bak # 备份
-rw-r--r-- 1 root root  14 Jul  7 23:22 pkg_version
-rw------- 1 root root 615 Jul  8 12:46 registry.json


cxloge@synocxloge:~$ sudo cat /var/packages/ContainerManager/etc/dockerd.json
{"data-root":"/var/packages/ContainerManager/var/docker","log-driver":"db","registry-mirrors":[],"storage-driver":"btrfs"}

cxloge@synocxloge:~$ sudo vi /var/packages/ContainerManager/etc/dockerd.json
cxloge@synocxloge:~$ sudo cat /var/packages/ContainerManager/etc/dockerd.json
{
        "data-root": "/var/packages/ContainerManager/var/docker",
        "log-driver": "db",
        "registry-mirrors": [],
        "storage-driver": "btrfs",
        "insecure-registries" : [  "xx.xxx.31.240:1923","xx.xxx.31.37:7300" ] ## 添加该配置的私有化仓库的地址端口
}

重启docker应用,
然后登录docker login -u cxloge -p password xx.xx.31.240:1923
或重新docker pull xx.xx.31.240:1923/library/postgres:15.2
验证配置是否生效,需要root权限可以使用sudo

# 登录
cxloge@synocxloge:~$ docker login -u cxloge -p password  xx.xx.31.240:1923
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/auth": dial unix /var/run/docker.sock: connect: permission denied
cxloge@synocxloge:~$ sudo docker login -u cxloge -p password xx.xx.31.240:1923
Password: 
Sorry, try again.
Password: 
Sorry, try again.
Password: 
WARNING! Using --password via the CLI is insecure. Use --password-stdin.
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

# docker pull
cxloge@synocxloge:~$ sudo docker pull xx.xx.31.240:1923/library/postgres:15.2
Password: 
15.2: Pulling from library/postgres
f1f26f570256: Pull complete 
1c04f8741265: Pull complete 
dffc353b86eb: Pull complete 
18c4a9e6c414: Pull complete 
81f47e7b3852: Pull complete 
5e26c947960d: Pull complete 
a2c3dc85e8c3: Pull complete 
17df73636f01: Pull complete 
713535cdf17c: Pull complete 
52278a39eea2: Pull complete 
4ded87da67f6: Pull complete 
05fae4678312: Pull complete 
56b4f4aeea2d: Pull complete 
Digest: sha256:f1f635486b8673d041e2b180a029b712a37ac42ca5479ea13029b53988ed164c
Status: Downloaded newer image for xx.xx.31.240:1923/library/postgres:15.2
xx.xx.31.240:1923/library/postgres:15.2

参考链接

Docker Registry web私有化镜像仓库
https://blog.csdn.net/cxloge/article/details/128055209

posted on 2023-07-10 00:19  cxloge  阅读(390)  评论(0编辑  收藏  举报