在Ubuntu 22.04中
root@k8s-eu-1-master:~# sudo systemctl daemon-reload
root@k8s-eu-1-master:~# sudo systemctl enable docker
Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker
root@k8s-eu-1-master:~#
root@k8s-eu-1-master:~# sudo systemctl restart docker
root@k8s-eu-1-master:~#
root@k8s-eu-1-master:~# sudo docker pull cassandra:latest
Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:48086->127.0.0.53:53: read: connection refused
root@k8s-eu-1-master:~# sudo systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-11-08 20:22:55 CET; 11min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 272072 (dockerd)
Tasks: 15
Memory: 37.7M
CPU: 638ms
CGroup: /system.slice/docker.service
└─272072 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Nov 08 20:22:55 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:22:55.320001583+01:00" level=info msg="Daemon has completed initialization"
Nov 08 20:22:55 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:22:55.353839818+01:00" level=info msg="API listen on /run/docker.sock"
Nov 08 20:22:55 k8s-eu-1-master systemd[1]: Started Docker Application Container Engine.
Nov 08 20:23:07 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:23:07.456049976+01:00" level=warning msg="Error getting v2 registry: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:48086->127.0.0.53:53: read: connection refused"
Nov 08 20:23:07 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:23:07.456096778+01:00" level=info msg="Attempting next endpoint for pull after error: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:48086->127.0.0.53:53: read: connection refused"
Nov 08 20:23:07 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:23:07.458039838+01:00" level=error msg="Handler for POST /v1.43/images/create returned error: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:48086->127.0.0.53:53: read: connection refused"
Nov 08 20:32:06 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:32:06.231824815+01:00" level=warning msg="Error getting v2 registry: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:43104->127.0.0.53:53: read: connection refused"
Nov 08 20:32:06 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:32:06.231929019+01:00" level=info msg="Attempting next endpoint for pull after error: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:43104->127.0.0.53:53: read: connection refused"
Nov 08 20:32:06 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:32:06.233897769+01:00" level=error msg="Handler for POST /v1.43/images/create returned error: Get \"https://registry-1.docker.io/v2/\": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:43104->127.0.0.53:53: read: connection refused"
Nov 08 20:32:10 k8s-eu-1-master dockerd[272072]: time="2023-11-08T20:32:10.259620826+01:00" level=info msg="ignoring event" container=544ab9c3758d8293d505aead2429bd2a6fff065672bc83c171d4834393814dc6 module=libcontainerd namespace=moby topic=/tasks/delete type="*events.TaskDelete"
但hello-world
docker 示例运行良好:
root@k8s-eu-1-master:~# docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
这是以下的输出docker info
:
root@k8s-eu-1-master:~# docker info
Client: Docker Engine - Community
Version: 24.0.7
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.11.2
Path: /usr/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.21.0
Path: /usr/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 4
Running: 0
Paused: 0
Stopped: 4
Images: 1
Server Version: 24.0.7
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
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 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 61f9fd88f79f081d64d6fa3bb1a0dc71ec870523
runc version: v1.1.9-0-gccaecfc
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.15.0-88-generic
Operating System: Ubuntu 22.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 10
Total Memory: 58.86GiB
Name: k8s-eu-1-master
ID: ca48bc0b-922b-47b6-bae4-85d5d911436c
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
如何让它发挥作用?
我在进行 docker 构建时遇到了同样的问题,使用 @Raphael10 发布的下面的命令解决了这个问题。
通过在 /etc/resolv.conf 中添加这两行来解决
进而: