Docker部署
方式一
#下载软件源 wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo sed -i 's#download.docker.com#mirrors.ustc.edu.cn/docker-ce#g' /etc/yum.repos.d/docker-ce.repo #安装 yum install docker-ce -y #启动 systemctl enable docker systemctl start 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 sudo systemctl enable docker #测试运行 hello-world docker run hello-world
方式三
#更新yum包 sudo yum update #执行 Docker 安装脚本。 curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh #执行这个脚本会添加 docker.repo 源并安装 Docker。 #启动 Docker 进程 sudo systemctl start docker sudo systemctl enable docker
验证 docker 是否安装成功
在容器中执行一个测试的镜像。
sudo docker run hello-world
docker ps
docker-compose部署
方式一
curl -L https://github.com/docker/compose/releases/download/1.24.0-rc3/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
方式二
yum update -y yum install docker epel-release python-pip -y pip install --upgrade pip pip install docker-compose
docker加速
参考docker.hub:https://www.daocloud.io/mirror
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io systemctl restart docker.service