centos7部署docker-ce 和 docker-compose
准备工作
1 2 3 4 5 6
| $ docker
sudo yum remove docker docker-common container-selinux docker-selinux docker-engine 安装 yum-utils,它提供了 yum-config-manager,可用来管理yum源 sudo yum install -y yum-utils
|
安装docker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| yum update
wget -P /etc/yum.repos.d/ https://download.docker.com/linux/centos/docker-ce.repo
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
wget -O /etc/yum.repos.d/docker-ce.repo https://repo.huaweicloud.com/docker-ce/linux/centos/docker-ce.repo sudo sed -i 's+download.docker.com+repo.huaweicloud.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
sudo yum clean all
sudo yum install -y docker-ce docker-ce-cli containerd.io
yum list docker-ce --showduplicates | sort -r
yum install -y docker-ce-18.03.0.ce-1.el7.centos
yum install docker -y
docker -v
|
卸载docker
1
| sudo yum remove docker-ce
|
配置网络加速
1 2
| vim /etc/docker/daemon.json
|
1 2 3 4 5 6 7
| { "registry-mirrors": [ "https://3oq8m6tn.mirror.aliyuncs.com", "https://hub-mirror.c.163.com", "https://mirror.baidubce.com" ] }
|
1 2
| sudo systemctl daemon-reload sudo systemctl restart docker
|
设置docker相关信息
- 设置docker开机启动项
systemctl enable docker.service
- 关闭docker开机启动项
systemctl stop docker.service
- 检查docker当前运行情况
systemctl status docker
- 若未启动则启动docker
systemctl start docker
,若启动了可以重启systemctl restart docker
- 检查docker运行情况
service docker status
部署docker-compsoe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| yum install epel-release yum install -y python-pip
pip install --upgrade pip
yum -y install python3-pip -y
pip install --upgrade setuptools
python -m pip install --upgrade pip python3 -m pip install --upgrade pip
pip install docker-compose pip3 install docker-compose
|
参考文档
阿里云CentOS 7上安装配置Docker
How To Install and Use Docker Compose on CentOS 7