Docker 安装
# 1、卸载旧版本
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 2、安装依赖项
$ sudo yum install -y yum-utils
# 3、设置镜像仓库(阿里云)
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
## 网上搜索"docker 阿里云镜像地址"
# 4、安装docker (docker-ce社区版、ee企业版)
$ yum makecache fast
$ sudo yum install docker-ce docker-ce-cli containerd.io
# 5、启动docker
$ systemctl start docker
# 6、查看是否安装成功
$ docker version
# 7、测试一下hello-world
$ docker run hello-world
==
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:e7c70bb24b462baa86c102610182e3efcb12a04854e8c582838d92970a09f323
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
==
# 8、查看镜像列表
$ docker images
==
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 10 months ago 13.3kB
==
# 9、卸载镜像
$ yum remove docker-ce docker-ce-cli containerd.io
$ rm -rf /var/lib/docker # docker的默认工作路径
10、镜像下载慢?镜像加速
$ sudo mkdir -p /etc/docker
$ sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://1nj0zren.mirror.aliyuncs.com",
"https://docker.mirrors.ustc.edu.cn",
"http://f1361db2.m.daocloud.io",
"https://registry.docker-cn.com"
]
}
EOF
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker