安装Docker

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 安装依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2

# 添加docker下载仓库
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# 安装docker-ce
sudo yum install docker-ce

# 启动docker-ce
sudo systemctl start docker

# 验证
sudo docker --version

安装docker-compose

1
2
3
4
5
6
7
8
9
10
11
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

#如果下载不动,则使用
sudo curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

#如果出现sudo docker-compose提示找不到命令,则使用
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

docker-compose --version

解决docker速度太慢问题

在 /etc/docker/daemon.json 文件中添加以下参数(没有该文件则新建)

1
2
3
{
"registry-mirrors": ["https://9cpn8tt6.mirror.aliyuncs.com"]
}

重启服务

1
2
systemctl daemon-reload
systemctl restart docker