1. Docker部署
1.1 方式一:
- 下载软件源
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
1.2 方式二:
- 安装一些必要的系统工具:
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
1.3 方式三:
- 更新yum包
sudo yum update
- 执行 Docker 安装脚本,这个脚本会添加
源并安装docker.repo
。Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
-
进程Docker
sudo systemctl start docker
sudo systemctl enable docker
- 验证
是否安装成功并在容器中执行一个测试的镜像。Docker
sudo docker run hello-world
docker ps
2. docker
加速:
docker
- 2.1 参考docker.hub
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io
systemctl restart docker.service
或者
- 2.2 配置阿里云镜像加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://s3w3uu4l.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
3. 部署 docker-compose
docker-compose
3.1 方式一
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
3.2 方式二
yum update -y
yum install docker epel-release python-pip -y
pip install --upgrade pip
pip install docker-compose