ubuntu20.04下默认是snap安装的docker。安装位置和apt安装的不一样。所以daemon.json的位置也不一样。国内网上说的都是往/ect/docker/daemon.json里添加
"registry-mirrors": [
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
]
统统都不对。
google一下。原来在这里。/var/snap/docker/current/config/daemon.json
本来就有这个文件,不用新建。
往里加了"registry-mirrors"这一段。然后呢重启docker。
怎么重启呢?
国内网上告诉你systemctl restart docker。你会发现
Failed to restart docker.service: Unit docker.service not found.
网上一大堆人告诉你重装docker。其实snap安装的docker。用snap命令就行了。
snap restart docker
搞定!文章来源:https://www.toymoban.com/news/detail-500571.html
xxx@ubuntu:/tmp# docker info文章来源地址https://www.toymoban.com/news/detail-500571.html
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 1
Server Version: 20.10.17
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: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
runc version:
init version: de40ad0
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-132-generic
Operating System: Ubuntu Core 18
OSType: linux
Architecture: x86_64
CPUs: 6
Total Memory: 7.607GiB
Name: ubuntu2004s
ID: I3F2:HD62:YSLM:GIGZ:JAB2:RBEI:MHNF:PDXT:Z3JQ:MY6R:SS72:S252
Docker Root Dir: /var/snap/docker/common/var-lib-docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
http://hub-mirror.c.163.com/
https://docker.mirrors.ustc.edu.cn/
https://registry.docker-cn.com/
Live Restore Enabled: false
到了这里,关于ubuntu20.04以及更高版本下docker添加国内镜像的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!