1. yum安装gcc相关环境
yum -y install gcc
yum -y install gcc-c++
2. 卸载旧版本(非必要)
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
3. 安装需要的软件包
yum install -y yum-utils
4. 设置镜像仓库
# 正确推荐使用国内的
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
5. 安装Docker
yum install docker-ce docker-ce-cli containerd.io
6. 启动Docker
systemctl start docker
7. 设置Docker开机自启
systemctl enable docker
8. 修改Docker的配置文件
- vim /etc/docker/daemon.json
{
"data-root":"/mnt/docker" # 默认docker的数据存放路径
}
- 重启docker
systemctl restart docker
- 验证修改是否成功
docker info|grep 'Docker Root Dir'
#结果如下所示:
Docker Root Dir: /mnt/docker
9. 验证Docker是否安装完成
- docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:6e8b6f026e0b9c419ea0fd02d3905dd0952ad1feea67543f525c73a0a790fefb
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/
10. 安装docker-compose
curl -SL https://get.daocloud.io/docker/compose/releases/download/v2.16.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# 国内
curl -SL https://get.daocloud.io/docker/compose/releases/download/v2.16.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# 添加执行权限
chmod +x /usr/local/bin/docker-compose
# 软连接
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# 验证
docker-compose version
标签:bin,compose,笔记,常见问题,yum,docker,Docker,latest
From: https://www.cnblogs.com/JentZhang/p/17212818.html