ubuntu中怎么配置Docker-CE镜像加速,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。实验环境操作系统:Ubuntu 18.04.4 LTSLAN IP :192.
ubuntu中怎么配置Docker-CE镜像加速,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
实验环境
操作系统:Ubuntu 18.04.4 LTS
LAN IP :192.168.3.22
Docker是现代软件开发和devops持续集成和部署管道中不可或缺的一部分,大部分公司都使用容器化技术,降低服务器成本。
安装必要的系统资源库
root@linuxcool:~$ sudo apt-get updateroot@linuxcool:~$ sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
安装GPG证书
root@linuxcool:~$ curl -fsSL Https://mirrors.nwafu.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Docker服务器在国外,如果使用docker.io来安装docker会非常慢,有时候还会超时断开导致无法安装成功;所以,我这里使用的是国内“西北农林科技大学网络与教育技术中心”镜像加速,国内还有很多镜像加速站点,比如:阿里云、腾讯云、网易、清华大学等,
更新系统并安装Docker-CE
root@linuxcool:~$ sudo apt-get -y updateroot@linuxcool:~$ sudo apt-get -y install docker-ce
通过以上命令安装的是docker最新版本,如果要安装docker,请继续阅读下文,
查找Docker-CE的版本
apt-cache madison docker-ce docker-ce | 5:19.03.8~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.7~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.6~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.5~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.4~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.3~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.2~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.1~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:19.03.0~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.9~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.8~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.7~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.6~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.5~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.4~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.3~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.2~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.1~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:18.09.0~3-0~ubuntu-bionic | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 18.06.3~ce~3-0~ubuntu | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 18.06.2~ce~3-0~ubuntu | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 18.06.1~ce~3-0~ubuntu | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 18.06.0~ce~3-0~ubuntu | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages docker-ce | 18.03.1~ce~3-0~ubuntu | https://mirrors.aliyun.com/docker-ce/linux/ubuntu bionic/stable amd64 Packages
安装指定版本的Docker-CE,比如要安装19.03.8~3-0~ubuntu-bionic
root@linuxcool:~$ sudo apt-get -y install docker-ce=19.03.8~3-0~ubuntu-bionic
安装校验
root@linuxcool:~$ sudo docker versionClient: Docker Engine - CommUnity Version: 19.03.8 api version: 1.40 Go version: go1.12.17 git commit: afacb8b7f0 Built: Wed Mar 11 01:25:46 2020 OS/Arch: linux/amd64 Experimental: falseServer: Docker Engine - Community Engine: Version: 19.03.8 API version: 1.40 (minimum version 1.12) Go version: go1.12.17 Git commit: afacb8b7f0 Built: Wed Mar 11 01:24:19 2020 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.13 GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429 runc: Version: 1.0.0-rc10 GitCommit: dc9208a3303feef5b3839f4323D9beb36df0a9dd docker-init: Version: 0.18.0 GitCommit: fec3683
配置镜像加速
#创建daemon.JSON配置文件root@linuxcool:~$ sudo vim /etc/docker/daemon.json{ "reGIStry-mirrors": ["https://dockerhub.mirrors.nwafu.edu.cn/"]}#默认daemon.json文件不存在,如果daemon.json文件不存在,自己创建
加载配置,重启docker服务
root@linuxcool:~$ sudo systemctl daemon-reloadroot@linuxcool:~$ sudo systemctl restart docker
验证镜像加速是否配置生效
root@linuxcool:~$ sudo docker info Client: Debug Mode: falseServer: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 19.03.8 Storage Driver: overlay2 Backing Filesystem: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: 5.3.0-51-generic Operating System: Ubuntu 18.04.4 LTS OSType: linux Architecture: x86_64 CPUs: 8 Total Memory: 15.64GiB Name: linuxcool ID: K252:G32L:GWWN:J5FE:3MFZ:2ITG:UE7Y:Y26F:Qt3Q:2PLS:HCUX:PJYZ 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://dockerhub.mirrors.nwafu.edu.cn/ Live Restore Enabled: falseWARNING: No swap limit support
Registry Mirrors默认是docker.io,如果看到Registry Mirrors变https://dockerhub.mirrors.nwafu.edu.cn说明配置已经生效。
docker服务管理
#自启服务root@linuxcool:~$ sudo systemctl enable docker.service#服务状态root@linuxcool:~$ sudo systemctl status docker.service#启动服务root@linuxcool:~$ sudo systemctl start docker.service#重启服务root@linuxcool:~$ sudo systemctl restart docker.service#停止服务root@linuxcool:~$ sudo systemctl stop docker.service
拉取镜像
root@linuxcool:~$ sudo docker pull Centos:8.1.19118.1.1911: Pulling from library/centos8a29a15cefae: Pull complete Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700Status: Downloaded newer image for centos:8.1.1911docker.io/library/centos:8.1.1911
关于Ubuntu中怎么配置Docker-CE镜像加速问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注编程网精选频道了解更多相关知识。
--结束END--
本文标题: Ubuntu中怎么配置Docker-CE镜像加速
本文链接: https://lsjlt.com/news/242738.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
2024-05-24
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0