适合于 CentOS 系统

docker 一键安装

1
curl -sSL http://img.sgfoot.com/sh/docker-install.sh |sudo sh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
################
# CentOS 一键安装
# From: sgfoot.com
#################

# 卸载旧版本
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine


# 设置仓库
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

# 使用阿里源地址
sudo yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo


# 安装 Docker Engine
sudo yum install docker-ce docker-ce-cli containerd.io -y

# 启动
systemctl start docker

# 测试一下
sudo docker run hello-world

echo "安装完毕"

docker-compose 安装

 docker-compose 是负责 docker 编排使用的

1
2
3
4
5
curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

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

docker-compose -h

docker 加速

推荐使用阿里云 docker 加速

使用流程: https://cr.console.aliyun.com/cn-hangzhou/instances/repositories

找到镜像加速器

image-20200826111636483

1
2
3
4
5
6
7
8
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://sziho4ql.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker