主机清单:172.16.0.30 四核4G 80G硬盘 主机名:devops-1 系统:centos7.6 安装docker和docker-compose 1.安装docker和常用的软件包 [root@devops-1 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 2.安装docker-ce 添加阿里云的docker-ce的源 [root@devops-1 ~]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 替换源 [root@devops-1 ~]# sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo 安装docker-ce [root@devops-1 ~]# yum -y install docker-ce 设置docker开机自启动,并立即启动 [root@devops-1 ~]# systemctl enable docker --now 添加国内的加速地址 [root@devops-1 ~]# vim /etc/docker/daemon.json 添加如下内容 { "registry-mirrors":["https://rsbud4vc.mirror.aliyuncs.com","https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn","https://ockerhub.azk8s.cn","http://hub-mirror.c.163.com","http://qtid6917.mirror.aliyuncs.com", "https://rncxm540.mirror.aliyuncs.com"], "exec-opts": ["native.cgroupdriver=systemd"] } 重启docker [root@devops-1 ~]# systemctl restart docker 或安装指定版本的Docker-CE: Step 1: 查找Docker-CE的版本: # yum list docker-ce.x86_64 --showduplicates | sort -r Loading mirror speeds from cached hostfile Loaded plugins: branch, fastestmirror, langpacks docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable Available Packages Step2: 安装指定版本的Docker-CE: (VERSION例如上面的17.03.0.ce.1-1.el7.centos) # yum -y install docker-ce-[VERSION] 3.安装docker-compose 进入/usr/local/bin目录里 [root@devops-1 ~]# cd /usr/local/bin 下载docker-compose,这里可能需要科学上网,可能下载不下来 [root@devops-1 ~]# wget https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-Linux-x86_64 重新命名docker-compose-Linux-x86_64为docker-compose [root@devops-1 ~]# rename /usr/local/bin/docker-compose-Linux-x86_64 docker-compose docker-compose-Linux-x86_64 添加执行权限 [root@devops-1 ~]# chmod +x /usr/local/bin/docker-compose 查看docker-compose版本 [root@devops-1 ~]# docker-compose version 返回结果: docker-compose version 1.25.0-rc4, build 8f3c9c58 docker-py version: 4.1.0 CPython version: 3.7.4 OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019