CentOS7.4离线安装docker及docker-compose

公司内部网络限制访问权限,只有少量服务器可以访问外网,组内进行一些培训,需要联网安装dockerji docker-compose,但是全部开外网,不太现实,考虑后将所有需要的rpm包下载后分发给各位使用者。

  1. 安装yumdownloader工具
  • yum install -y yum-utils
  1. 创建rpm存储目录
  • mkdir install_docker_rpm
  • yumdownloader --resolve --destdir=/root/install_docker_rpm/ device-mapper-persistent-data lvm2
  1. 安装docker rpeo源
  • yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  1. 下载docker所有依赖包
  • yumdownloader --resolve --destdir=/root/install_docker_rpm/ docker-ce
  1. 下载docker-compose下载docker-compose
  • curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-uname -s-uname -m -o install_docker_rpm/docker-compose
  1. 安装本地rpm
  • yum install -y *.rpm
  1. 启动docker
  • systemctl start docker
  • systemctl enable docker
  • docker --version
  1. 安装docker-compose
  • cp ./docker-compose /usr/bin/
  • chmod +x /usr/bin/docker-compose
  • docker-compose --version
  1. 简单脚本
#!/bin/bash
#关闭防火墙
systemctl disable firewalld
systemctl stop firewalld
echo 'disable firewalld'
#安装docker需要的rpm包
yum localinstall -y ./*.rpm
echo 'install docker rpm'
#启动dcoker
systemctl start docker
systemctl enable docker
echo $(docker --version)
echo 'kubernetes install OK!!!'
#配置docker-compose
cp ./docker-compose /usr/bin/
chmod +x /usr/bin/docker-compose
echo $(docker-compose --version)
#导入hello-world
docker load -i hello-world.tar

你可能感兴趣的:(CentOS7.4离线安装docker及docker-compose)