1、问题描述
由于某些原因,导致Docker
镜像在国内下载速度特别慢。所以为了沉浸式开发。最好切换为国内源。这里以163 的镜像仓库举例。首先修改/etc/docker/daemon.json
配置文件。
sudo vi /etc/docker/daemon.json
将该文件内容替换为阿里源。修改后的/etc/docker/daemon.json
文件为:
{ "registry-mirrors": ["http://hub-mirror.c.163.com"] }
然后使用systemctl restart docker
命令重启Docker
即可。然后使用docker info
命令查看镜像仓库信息,结果如下:
root@ubuntu:~# docker info Client: Debug Mode: false Server: Containers: 3 Running: 0 Paused: 0 Stopped: 3 Images: 3 Server Version: 19.03.8 Storage Driver: overlay2 Backing Filesystem: <unknown> Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs 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 Default Runtime: runc Init Binary: docker-init containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd init version: fec3683 Security Options: apparmor seccomp Profile: default Kernel Version: 4.15.0-97-generic Operating System: Ubuntu 18.04.4 LTS OSType: linux Architecture: x86_64 CPUs: 12 Total Memory: 7.767GiB Name: ubuntu ID: 2XV6:BJ7Q:6BIH:4FIR:HEPL:3GF7:33A2:GGTU:EQMB:EKGX:EO34:5J44 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: http://hub-mirror.c.163.com/ Live Restore Enabled: false WARNING: No swap limit support
2、总结
书上的代码直接运行绝大部分是对的,但是总有一些软件的更新使得作者无能为力。之前的API是对的,但是之后就废弃了或修改了是常有的事。所以我们需要跟踪源代码。这只是一个小小的问题,如果没有前辈的无私奉献,很难想象我们自己一天能学到多少内容。感谢各位前辈的辛勤付出,让我们少走了很多的弯路!