docker pull/login总是使用HTTP而不是https



我在ubuntu live 22.04上安装了一个docker,它安装在vmware上。我设置了docker守护进程。像这样的Json

{
"registry-mirrors" : [
"https://my-domain.com"
],
"insecure-registries": [
]
}

其中https://my-domain.com是我的私有注册表,并且它安装在另一台机器上。但是当我使用docker pull或登录我的私有注册表时,docker总是使用http而不是https

root@root:~# docker pull my-domain.com/example/hello-world
Error response from daemon: Get "http://my-domain.com/v2/": dial tcp [::1]:80: connect: connection refused
root@root:~# docker login my-domain.com
Username: ******
Password: ******
Error response from daemon: Get "http://my-domain.com/v2/": dial tcp [::1]:80: connect: connection refused

为什么我的docker总是使用http而不是https?我没有设置相关的配置。

这是我的docker信息:

Client:
Context:    default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.9.1-docker)
compose: Docker Compose (Docker Inc., v2.14.1)
scan: Docker Scan (Docker Inc., v0.23.0)
Server:
Containers: 1
Running: 1
Paused: 0
Stopped: 0
Images: 2
Server Version: 20.10.22
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: systemd
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9ba4b250366a5ddde94bb7c9d1def331423aa323
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
cgroupns
Kernel Version: 5.15.0-57-generic
Operating System: Ubuntu 22.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.896GiB
Name: suyj
ID: HB2H:FWFC:GOZT:K7HR:EFLZ:Z6TM:MJCC:MS3W:EO44:NZ4G:W3WZ:TWGJ
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://my-domain.com/
Live Restore Enabled: false

我知道我的docker发生了什么。我更改了配置(/etc/netplan/00-installer-config.yaml)来固定虚拟机的IP地址。

network:
ethernets:
ens33:
dhcp4: false
dhcp6: true
optional: true
addresses:
- 192.168.188.137/24
routes:
- to: default
via: 192.168.188.2
nameservers:
addresses:
- 114.114.114.114
- 8.8.8.8
search:
- localhost
- local
version: 2
renderer: NetworkManager

但是我的域名是内部网,不是公共的。当我ping私有注册表域时,它没有返回正确的IP,因为它试图从公网找到域IP。

root@root:~# ping my-domain.com
PING docker-iottest.midea.com(ip6-localhost (::1)) 56 data bytes
64 bytes from ip6-localhost (::1): icmp_seq=1 ttl=64 time=0.040 ms
64 bytes from ip6-localhost (::1): icmp_seq=2 ttl=64 time=0.034 ms

我必须设置vmware网络网关作为DNS地址进行分析。

network:
ethernets:
ens33:
......
nameservers:
addresses:
- 192.168.188.2  # add the vmware network gateway IP
- 114.114.114.114
- 8.8.8.8
......

当我重新加载网络或重新加载系统时,它工作并返回正确的IP。

最新更新