天天看点

Docker 和 docker-compose 部署详解

Docker 和 docker-compose 部署详解

镜像下载、域名解析、时间同步请点击

阿里巴巴开源镜像站

一、 Docker 部署

方式一:

1.安装一些必要的系统工具:

sudo yum install -y yum-utils device-mapper-persistent-data lvm2           

2.添加软件源信息:

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo           

3.更新

yum

缓存:

sudo yum makecache fast           

4.安装

Docker-ce

sudo yum -y install docker-ce           

5.启动

Docker

后台服务:

sudo systemctl start docker
sudo systemctl enable docker           

6.测试运行

hello-world

docker run hello-world           
方式二:

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           

2.安装

yum install docker-ce -y           

3.启动

systemctl enable docker
systemctl start docker           
方式三:

1.更新yum包

sudo yum update           

2.执行 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           

4.验证

Docker

是否安装成功并在容器中执行一个测试的镜像。

sudo docker run hello-world
docker ps           

二、Docker 镜像加速

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.

配置阿里云镜像加速器
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           

三、部署 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           
提供全面,高效和稳定的系统镜像、应用软件下载、域名解析和时间同步服务。”