我已根据以下评论更新了该问题。
以下是删除、安装、测试和显示有关 docker 的信息的命令
删除 Docker 密钥
sudo apt-key list Docker
sudo apt-key del "9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88"
sudo apt-key list Docker
卸载docker
# sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get remove docker docker.io containerd runc
注释掉docker仓库
sudo gedit /etc/apt/sources.list.d/docker.list
sudo more /etc/apt/sources.list.d/docker.list
# deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu focal stable
安装 docker
sudo apt install --reinstall docker.io
添加组
sudo groupadd docker
sudo usermod -aG docker $USER
Docker 信息
$ docker info
Client:
Context: default
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 20.10.12
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
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: runc io.containerd.runc.v2 io.containerd.runtime.v1.linux
Default Runtime: runc
Init Binary: docker-init
containerd version:
runc version:
init version:
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.15.0-53-generic
Operating System: Ubuntu 20.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 62.5GiB
Name: cd0254nb032364
ID: 23TM:HHHH:IE6K:ZS3W:UAQJ:6D4X:OZHT:VCTD:EHT2:YEXJ:EL3J:WLWS
Docker Root Dir: /var/lib/docker
Debug Mode: true
File Descriptors: 31
Goroutines: 49
System Time: 2022-11-29T14:03:27.77815013-05:00
EventsListeners: 0
HTTP Proxy: xxx
HTTPS Proxy: xxx
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Docker 版本
$ docker version
Client:
Version: 20.10.12
API version: 1.41
Go version: go1.16.2
Git commit: 20.10.12-0ubuntu2~20.04.1
Built: Wed Apr 6 02:14:38 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
Server:
Engine:
Version: 20.10.12
API version: 1.41 (minimum version 1.12)
Go version: go1.16.2
Git commit: 20.10.12-0ubuntu2~20.04.1
Built: Thu Feb 10 15:03:35 2022
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.5.9-0ubuntu1~20.04.5
GitCommit:
runc:
Version: 1.1.0-0ubuntu1~20.04.2
GitCommit:
docker-init:
Version: 0.19.0
GitCommit:
打印日期,测试docker
john@cd0254nb032364:~$ date
Tue 29 Nov 2022 02:20:46 PM EST
john@cd0254nb032364:~$ docker run --log-driver "syslog" hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Extracting [==================================================>] 2.479kB/2.479kB
^C
显示系统日志
Nov 29 14:13:46 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:13:46.399481658-05:00" level=debug msg="found match for linux/amd64 with media type application/vnd.docker.distribution.manifest.v2+json, digest sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4"
Nov 29 14:17:01 cd0254nb032364 CRON[99485]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Nov 29 14:19:33 cd0254nb032364 kernel: [708152.538463] i915 0000:00:02.0: [drm] *ERROR* Atomic update failure on pipe A (start=301608 end=301609) time 117 us, min 1064, max 1079, scanline start 1062, end 1080
Nov 29 14:20:52 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:52.955928670-05:00" level=debug msg="Calling HEAD /_ping"
Nov 29 14:20:52 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:52.956661084-05:00" level=debug msg="Calling POST /v1.41/containers/create"
Nov 29 14:20:52 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:52.956842881-05:00" level=debug msg="form data: {\"AttachStderr\":true,\"AttachStdin\":false,\"AttachStdout\":true,\"Cmd\":null,\"Domainname\":\"\",\"Entrypoint\":null,\"Env\":null,\"HostConfig\":{\"AutoRemove\":false,\"Binds\":null,\"BlkioDeviceReadBps\":null,\"BlkioDeviceReadIOps\":null,\"BlkioDeviceWriteBps\":null,\"BlkioDeviceWriteIOps\":null,\"BlkioWeight\":0,\"BlkioWeightDevice\":[],\"CapAdd\":null,\"CapDrop\":null,\"Cgroup\":\"\",\"CgroupParent\":\"\",\"CgroupnsMode\":\"\",\"ConsoleSize\":[0,0],\"ContainerIDFile\":\"\",\"CpuCount\":0,\"CpuPercent\":0,\"CpuPeriod\":0,\"CpuQuota\":0,\"CpuRealtimePeriod\":0,\"CpuRealtimeRuntime\":0,\"CpuShares\":0,\"CpusetCpus\":\"\",\"CpusetMems\":\"\",\"DeviceCgroupRules\":null,\"DeviceRequests\":null,\"Devices\":[],\"Dns\":[],\"DnsOptions\":[],\"DnsSearch\":[],\"ExtraHosts\":null,\"GroupAdd\":null,\"IOMaximumBandwidth\":0,\"IOMaximumIOps\":0,\"IpcMode\":\"\",\"Isolation\":\"\",\"KernelMemory\":0,\"KernelMemoryTCP\":0,\"Links\":null,\"LogConfig\":{\"Config\":{},\"Type\":\"syslog\"},\"MaskedPaths\":null,\"Memory\":0,\"MemoryReservation\":0,\"MemorySwap\":0,\"MemorySwappiness\":-1,\"NanoCpus\":0,\"NetworkMode\":\"default\",\"OomKillDisable\":false,\"OomScoreAdj\":0,\"PidMode\":\"\",\"PidsLimit\":0,\"PortBindings\":{},\"Privileged\":false,\"PublishAllPorts\":false,\"ReadonlyPaths\":null,\"ReadonlyRootfs\":false,\"RestartPolicy\":{\"MaximumRetryCount\":0,\"Name\":\"no\"},\"SecurityOpt\":null,\"ShmSize\":0,\"UTSMode\":\"\",\"Ulimits\":null,\"UsernsMode\":\"\",\"VolumeDriver\":\"\",\"VolumesFrom\":null},\"Hostname\":\"\",\"Image\":\"hello-world\",\"Labels\":{},\"NetworkingConfig\":{\"EndpointsConfig\":{}},\"OnBuild\":null,\"OpenStdin\":false,\"Platform\":null,\"StdinOnce\":false,\"Tty\":false,\"User\":\"\",\"Volumes\":{},\"WorkingDir\":\"\"}"
Nov 29 14:20:52 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:52.959206339-05:00" level=debug msg="Calling GET /v1.41/info"
Nov 29 14:20:52 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:52.968076485-05:00" level=debug msg="Calling POST /v1.41/images/create?fromImage=hello-world&tag=latest"
Nov 29 14:20:52 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:52.976774280-05:00" level=debug msg="Trying to pull hello-world from https://registry-1.docker.io v2"
Nov 29 14:20:53 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:53.548021023-05:00" level=debug msg="Pulling ref from V2 registry: hello-world:latest"
Nov 29 14:20:53 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:53.548058753-05:00" level=debug msg="docker.io/library/hello-world:latest resolved to a manifestList object with 11 entries; looking for a unknown/amd64 match"
Nov 29 14:20:53 cd0254nb032364 dockerd[64419]: time="2022-11-29T14:20:53.548075219-05:00" level=debug msg="found match for linux/amd64 with media type application/vnd.docker.distribution.manifest.v2+json, digest sha256:f54a58bc1aac5ea1a25d796ae155dc228b3f0e11d046ae276b39c4bf2f13d8c4"
Nov 29 14:21:30 cd0254nb032364 auditmanager: Received wakeup signal before sleep finished
在单独的终端中显示 docker 进程。请注意,没有显示任何进程。
john@cd0254nb032364:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
john@cd0254nb032364:~$
我不知道这是否有用,但我尝试了该命令
ohn@cd0254nb032364:~$ docker pull busybox
Using default tag: latest
latest: Pulling from library/busybox
405fecb6a2fa: Extracting [==> ] 32.77kB/773kB
而且,该命令似乎无法提取图像。如果我列出图像,系统上没有任何图像,包括 hello-world。
john@cd0254nb032364:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
john@cd0254nb032364:~$
所以,问题可能出在我的互联网连接上,我无法下载图片。有办法检查吗?可以手动下载图片吗?
我该如何调试或修正设置以便 docker 命令 hello-world 运行?
答案1
您似乎缺少了一些重要组件。请注意:
Runtimes: io.containerd.runtime.v1.linux runc io.containerd.runc.v2
Default Runtime: runc
Init Binary: docker-init
containerd version:
runc version:
init version:
在工作系统上,应显示以下内容:(版本号来自我的 Ubuntu 22.04,其中 Docker 20.10.21 是从 Docker 存储库安装的)
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 1c90a442489720eec95342e1789ee8a5e1b9536f
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
如果您从 Ubuntu 存储库安装了 Docker,请运行:(我认为很多人不会使用此选项,但仍然......)
sudo apt install --reinstall docker.io
如果你从 Docker 存储库安装了 Docker,请运行:
sudo apt install --reinstall docker-ce docker-ce-cli containerd.io docker-compose-plugin
另外,请记住将您的用户添加到docker
组中。