In the process of using docker, we sometimes encounter some privatization deployment problems, that is, installing and using dokcer on some machines that cannot access the Internet, which leads to the problem of offline installation of docker
environment:
Check your current kernel version with the uname -r command
centos 7.0 kernel version 3.10.0-327.el7.x86_64
cents 7.2-1511
docker version 1.12.6
The basic idea:
On a machine that can connect to the external network (does not have docker installed, and is the same as the system version of the machine where docker is to be installed on the local area network), download the rpm and related dependencies through the yum command. Copy the downloaded rpm package to the LAN machine. Build local yum sources
Download the Docker offline installation package:
To download the docker offline installation package, you need to use the offline download command of yum. Generally, we use yum install to download the installation package and install it. After the installation is complete, delete the downloaded installation package.
yum provides a way to only download the installation package, but not install it:
yum install --downloadonly --downloaddir=/home/asit/dockerRpmdocker
With this command, we can download the docker-related rpm package to the /home/asit/dockerRpm directory, as shown in the figure:
Basic environment preparation:
turn off selinux: security subsystem
[root@localhost ~]# cat /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
Turn off Firewalld: Firewall
systemctl status firewalld View firewall status
systemctl stop firewalld turn off the firewall
systemctl disable firewalld disable firewall
systemctl status firewalld
firewall-cmd --state View firewall status
Build local yum sources:
Decompress CentOS-7-x86_64-DVD-1511.iso, copy the Packages in Centos7.2-1511, and change the name to yumInstallPackages as the local source library, and then copy the installation package in the downloaded docker rpm package into yumInstallPackages.
Upload yumInstallPackages to the /root directory
1. Install createrepo
[root@master ~]# rpm -ivh./yumInstallPackage/deltarpm-3.6-3.el7.x86_64.rpm
[root@master ~]# rpm -ivh./yumInstallPackage/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
[root@master ~]# rpm -ivh ./yumInstallPackage/python-deltarpm-3.6-3.el7.x86_64.rpm
[root@master ~]# rpm -ivh./yumInstallPackage/createrepo-0.9.9-28.el7.noarch.rpm
[root@master ~]# createrepo
This appears to prove that createrepo has been installed.
2. Create a new *.repo file
Delete the files in the /etc/yum.repo.d directory, create a new *.repo file, such as: local.repo, and configure
[root@master ~]# rm -rf /etc/yum.repos.d/CentOS-*
[root@master ~]# vi/etc/yum.repos.d/local.repo
[local_server]
name=Thisis a local repo
baseurl = file: /// root/yumInstallPackage
enabled=1
gpgcheck=0
3. Set the local source
Execute the following command, after success, the local source is set up
createrepo -d /root/yumInstallPackage/
Enter yum repolist to see if you can see the local sources built by yourself
clear cache, yum clean all
Create cache, yum makecache
4. Check whether the local source is configured successfully
Use the yum list to see if the new rpm package is output. If it can be queried, it proves that the configuration is successful.
Install Docker
Install
yuminstall docker
start docker
systemctl start docker
Automatically start docker on boot
systemctl enable docker
restart docker
systemctl restart docker
View docker information
docker info
View docker version
docker version