安装docker

#安装docker

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
先移除旧版docker
sudo yum remove docker
 
安装一些必要的系统工具
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

更新 yum 缓存
sudo yum makecache fast

安装 Docker-ce
sudo yum -y install docker-ce

启动 Docker 后台服务
sudo systemctl start docker

#安装docker-compose

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
1、下载docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

2、增加可执行权限
sudo chmod +x /usr/local/bin/docker-compose

3、添加软链接
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

4、确认版本
$ docker-compose --version

5、增加docker-compose命令补全
sudo yum install bash-completion -y

sudo curl \
    -L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
    -o /etc/bash_completion.d/docker-compose

#安装脚本

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#!/bin/bash

# 安装docker-compose
# 下载docker-compose 
curl -L "https://github.com/docker/compose/releases/download/1.29.2/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

# 增加docker-compose命令补全
yum install bash-completion -y
curl \
    -L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
    -o /etc/bash_completion.d/docker-compose