本实验在CentOS 7中完成
第一部分:安装Docker
这一部分是安装Docker,如果机器中已经安装过Docker,可以直接跳过
[root@VM-48-22-centos ~]# systemctl stop firewalld
[root@VM-48-22-centos ~]# systemctl disable firewalld
[root@VM-48-22-centos ~]# systemctl status firewalld
[root@VM-48-22-centos ~]# setenforce 0
[root@VM-48-22-centos ~]# getenforce
[root@VM-48-22-centos ~]# yum -y update
[root@VM-48-22-centos ~]# mkdir /etc/yum.repos.d/oldrepo
[root@VM-48-22-centos ~]# mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/oldrepo/
[root@VM-48-22-centos ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@VM-48-22-centos ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
[root@VM-48-6-centos ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@VM-48-22-centos ~]# yum clean all
[root@VM-48-22-centos ~]# yum makecache fast
[root@VM-48-22-centos ~]# yum list docker-ce --showduplicates | sort -r
[root@VM-48-22-centos ~]# yum -y install docker-ce
[root@VM-48-22-centos ~]# systemctl start docker
[root@VM-48-22-centos ~]# systemctl enable docker
[root@VM-48-22-centos ~]# ps -ef | grep docker
[root@VM-48-22-centos ~]# docker version
到这一步能正常输出docker版本,说明docker已经成功安装。
为了后续拉取镜像能更快,需要添加一个镜像:
[root@VM-48-22-centos ~]# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://x3n9jrcg.mirror.aliyuncs.com"]
}
重启docker。
后续需要用git拉取一些资源,所以要安装git,同样为了能够正常访问github,需要修改一下hosts文件。
[root@VM-48-22-centos ~]# systemctl daemon-reload
[root@VM-48-22-centos ~]# systemctl restart docker
[root@VM-48-22-centos ~]# yum -y install git
[root@VM-48-22-centos ~]# vi /etc/hosts
添加以下内容:
192.30.255.112 github.com git
第二部分:安装Docker-Compose
这一部分是安装Docker-Compose,如果已经安装过,可以直接跳过。
[root@VM-48-6-centos ~]# curl -L https://get.daocloud.io/docker/compose/releases/download/1.27.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 423 100<