Docker 安装及镜像加速器配置
前言
本次实验使用的操作系统镜像为 ubuntu-18.04.2-desktop
第一章 安装操作系统
1.1 软件下载
使用官方提供的Ubuntu 18.04.2 Desktop 镜像,下载地址:https://ubuntu.com/download
1.2 软件安装
此步骤省略
1.3 登录后输入以下命令,切入到 root 用户
rsecc@rsecc:~$ sudo -i
[sudo] password for rsecc:
第二章 Docker 安装
2.1 安装必要的系统工具
root@rsecc:~# apt-get update
root@rsecc:~# apt-get -y install apt-transport-https ca-certificates curl software-properties-common
2.2 安装GPG证书
root@rsecc:~# curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -
2.3 写入软件源信息
root@rsecc:~# add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
2.4 更新并安装Docker-CE
root@rsecc:~# apt-get -y update
root@rsecc:~# apt-get -y install docker-ce
2.5 启动 docker 并设置开机自启
root@rsecc:~# systemctl start docker
root@rsecc:~# systemctl enable docker
2.6 测试
root@rsecc:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5
Status: Downloaded newer image for hello-world:latest
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 镜像加速器
3.1 修改或创建 daemon 配置文件 /etc/docker/daemon.json 来使用加速器
root@rsecc:~# mkdir -p /etc/docker
root@rsecc:~# tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
3.2 重启 daemon 和 Docker
root@rsecc:~# systemctl daemon-reload
root@rsecc:~# systemctl restart docker
3.3 检查加速器是否生效
root@rsecc:~# docker info
……省略……
Registry Mirrors:
https://registry.docker-cn.com/
Live Restore Enabled: false
附录
Docker 镜像加速列表
Docker 中国官方镜像:https://registry.docker-cn.com
科大镜像站:https://docker.mirrors.ustc.edu.cn
阿里云:https://<your_code>.mirror.aliyuncs.com
[需要注册,获取专属的镜像加速链接]
七牛云:https://reg-mirror.qiniu.com
华为云:https://<your_code>.mirror.swr.myhuaweicloud.com
[需要注册,获取专属的镜像加速链接]
腾讯云:https://mirror.ccs.tencentyun.com
© 版权声明
文章:Docker 安装及镜像加速器配置
作者:Guangran
链接:https://www.rsecc.cn/62.html
声明:如无特别说明本文即为原创文章仅代表个人观点,版权归《广然笔记》所有,未经授权、请勿转载。
文章:Docker 安装及镜像加速器配置
作者:Guangran
链接:https://www.rsecc.cn/62.html
声明:如无特别说明本文即为原创文章仅代表个人观点,版权归《广然笔记》所有,未经授权、请勿转载。
THE END