您现在的位置是:首页 > 文章详情

Docker和docker-compose部署

日期:2020-01-31点击:574

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 加速:

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://f1361db2.m.daocloud.io systemctl restart docker.service

或者

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

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
原文链接:https://yq.aliyun.com/articles/743356
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章