Docker Installation
Published on
1. Environment Preparation
-
备份原yum 源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup -
CentOS设置新yum 源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo -
使用阿里云Docker Yum源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -
生成缓存
yum makecache -
卸载旧版本Docker
yum remove docker docker-common docker-selinux
2. Install Docker CE
-
安装需要的依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2 -
安装
yum install docker-ce -y -
启动docker
sudo systemctl start docker -
设置开机启动
sudo systemctl enable docker -
配置Docker 镜像加速
mkdir -p /etc/docker -
在新建目录下新建daemon.json,内容如下:
{ "registry-mirrors": ["https://bpavu6gm.mirror.aliyuncs.com"] } -
重新加载配置文件
systemctl daemon-reload -
重启docker
systemctl restart docker
3. Install Docker Compose
Download Docker Compose
wget https://github.com/docker/compose/releases/download/v2.19.1/docker-compose-linux-x86_64
Installation
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Verify Installation
docker-compose --version
Note: You can choose the corresponding version.