主要命令参考:https://docs.docker.com/engine/install/centos/
1、卸载系统之前的 docker
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、设置 docker repo 的 yum 位置
sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
4、安装 docker,以及 docker-cli
sudo yum install docker-ce docker-ce-cli containerd.io
5、启动 docker
sudo systemctl start docker
6、设置 docker 开机自启
sudo systemctl enable docker
7、测试 docker 常用命令,注意切换到 root 用户下 https://docs.docker.com/engine/reference/commandline/docker/
8、Docker配置阿里云镜像加速器
https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
执行以下命令即可:
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://2x0cdkie.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker