# centos7 联网安装docker
官方安装手册
https://docs.docker.com/install/linux/docker-ce/centos/
# 卸载旧版
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 安装一组工具
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
###
device-mapper-persistent-data # 存储驱动器相关
lvm2 # 逻辑卷相关
1
2
3
4
5
6
7
2
3
4
5
6
7
# yum设置 docker 存储库
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#清华大学源
sudo yum-config-manager \
--add-repo \
https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repo
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
根据需要更新 yum 缓存,可加快下载速度
sudo yum makecache fast
1
# yum安装docker
sudo yum install docker-ce docker-ce-cli containerd.io
sudo yum install docker-compose-plugin # 需要时再安装,功能为可使用yml文件配置服务
1
2
3
2
3
# docker启动
启动 docker
sudo systemctl start docker
1
重启 docker
sudo systemctl restart docker
1
设置 docker 开机启动
sudo systemctl enable docker
1
运行 hello-world 镜像,验证 docker
sudo docker run hello-world
1
# 镜像加速
由于国内网络问题,需要配置加速器来加速。
修改配置文件 /etc/docker/daemon.json
docker info # 查看信息
touch /etc/docker/daemon.json
vim /etc/docker/daemon.json
1
2
3
4
2
3
4
添加以下内容
{
"registry-mirrors": [
"https://sqectteq.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://reg-mirror.qiniu.com",
"http://registry.docker-cn.com"
]
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
之后重新启动服务
# 重新加载daemon文件
sudo systemctl daemon-reload
# 重启docker服务
sudo systemctl restart docker.service
sudo systemctl restart docker
sudo service docker restart # centos6
1
2
3
4
5
6
2
3
4
5
6
# 内存使用量
docker stats
← k8s win10安装Docker →