This document covers the procedure of setting up a Docker Engine on the Production environment of CentOS where internet access is not available.
To start the procedure we will need the following resources:
Proposed steps to resolve the problem:
Firstly, we will download all the required libraries and dependencies that a Docker engine would require. Then we package these dependencies in a single tar file and move this tar file to the machine where internet access is not available. Then we will install those binaries on that machine and we would have a perfectly running Docker Environment including docker-compose. We will need the following resources to perform this activity:
-
A Linux virtual machine with internet access to download the binaries of Docker Engine.
-
A CentOS Environment with restricted internet access on which we want to install Docker Engine.
Downloading Binaries:
Following steps are to be carried out at the machine where the internet is accessible.
-
Use the following command to set up the docker stable repository.
Bashcurl -sSL https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
-
Use the
yum list docker-ce --showduplicates | sort -rto list all available docker-ce packages.Bashyum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
-
Use
yum deplist docker-ce-17.12.0.ce-1.el7.centosto list dependency packages.Bashyum deplist docker-ce-18.03.1.ce-1.el7.centos
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: repo.inara.pk * extras: repo.inara.pk * updates: repo.inara.pk package: docker-ce.x86_64 18.03.1.ce-1.el7.centos dependency: /bin/sh provider: bash.x86_64 4.2.46-34.el7 dependency: container-selinux >= 2.9 provider: container-selinux.noarch 2:2.119.2-1.911c772.el7_8 dependency: device-mapper-libs >= 1.02.90-1 provider: device-mapper-libs.x86_64 7:1.02.170-6.el7 provider: device-mapper-libs.i686 7:1.02.170-6.el7 dependency: libcgroup provider: libcgroup.x86_64 0.41-21.el7 provider: libcgroup.i686 0.41-21.el7 dependency: libdevmapper.so.1.02()(64bit) provider: device-mapper-libs.x86_64 7:1.02.170-6.el7 dependency: libdevmapper.so.1.02(Base)(64bit) provider: device-mapper-libs.x86_64 7:1.02.170-6.el7 dependency: libdevmapper.so.1.02(DM_1_02_97)(64bit) provider: device-mapper-libs.x86_64 7:1.02.170-6.el7 dependency: libdl.so.2()(64bit) provider: glibc.x86_64 2.17-317.el7 dependency: libdl.so.2(GLIBC_2.2.5)(64bit) provider: glibc.x86_64 2.17-317.el7 dependency: libltdl.so.7()(64bit) provider: libtool-ltdl.x86_64 2.4.2-22.el7_3 dependency: libpthread.so.0()(64bit) provider: glibc.x86_64 2.17-317.el7 dependency: libpthread.so.0(GLIBC_2.2.5)(64bit) provider: glibc.x86_64 2.17-317.el7 dependency: libpthread.so.0(GLIBC_2.3.2)(64bit) provider: glibc.x86_64 2.17-317.el7 dependency: libseccomp >= 2.3 provider: libseccomp.x86_64 2.3.1-4.el7
-
The dependencies for docker and docker-compose are already figured out. Next, we need to
yumdownloadthe required libraries. Let’s make a directory nameddocker-ceand useyumdownloader --resolveto resolve the dependencies.Bashmkdir docker-ce yumdownloader --resolve docker-ce device-mapper-libs systemd libseccomp policycoreutils libcgroup policycontrol-python py-pip python-dev libffi-dev openssl-dev gcc libc-dev make
If
yumdownloaderis not present, download it by running:yum install yum-utils
-
If you
lsindocker-ce, you would see plenty of.rpmfiles downloaded in the directory.Bashls
audit-libs-2.8.5-4.el7.i686.rpm glibc-headers-2.17-317.el7.x86_64.rpm lvm2-2.02.187-6.el7.x86_64.rpm audit-libs-python-2.8.5-4.el7.x86_64.rpm kernel-headers-3.10.0-1160.2.2.el7.x86_64.rpm lvm2-libs-2.02.187-6.el7.x86_64.rpm bzip2-libs-1.0.6-13.el7.i686.rpm libattr-2.4.46-13.el7.i686.rpm lz4-1.8.3-1.el7.i686.rpm checkpolicy-2.5-8.el7.x86_64.rpm libcap-2.22-11.el7.i686.rpm lz4-1.8.3-1.el7.x86_64.rpm containerd.io-1.3.7-3.1.el7.x86_64.rpm libcap-2.22-11.el7.x86_64.rpm make-3.82-24.el7.x86_64.rpm container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm libcap-ng-0.7.5-4.el7.i686.rpm mpfr-3.1.1-4.el7.x86_64.rpm cpp-4.8.5-44.el7.x86_64.rpm libcgroup-0.41-21.el7.i686.rpm nspr-4.25.0-2.el7_9.x86_64.rpm cracklib-2.9.0-11.el7.i686.rpm libcgroup-0.41-21.el7.x86_64.rpm nss-softokn-freebl-3.53.1-6.el7_9.i686.rpm device-mapper-1.02.170-6.el7.x86_64.rpm libdb-5.3.21-25.el7.i686.rpm nss-softokn-freebl-3.53.1-6.el7_9.x86_64.rpm device-mapper-event-1.02.170-6.el7.x86_64.rpm libgcc-4.8.5-44.el7.i686.rpm nss-util-3.53.1-1.el7_9.x86_64.rpm device-mapper-event-libs-1.02.170-6.el7.x86_64.rpm libgcc-4.8.5-44.el7.x86_64.rpm pam-1.1.8-23.el7.i686.rpm device-mapper-libs-1.02.170-6.el7.i686.rpm libgcrypt-1.5.3-14.el7.i686.rpm pam-1.1.8-23.el7.x86_64.rpm device-mapper-libs-1.02.170-6.el7.x86_64.rpm libgomp-4.8.5-44.el7.x86_64.rpm pcre-8.32-17.el7.i686.rpm docker-ce-19.03.13-3.el7.x86_64.rpm libgpg-error-1.12-3.el7.i686.rpm policycoreutils-2.5-34.el7.x86_64.rpm docker-ce-cli-19.03.13-3.el7.x86_64.rpm libmpc-1.0.1-3.el7.x86_64.rpm policycoreutils-python-2.5-34.el7.x86_64.rpm elfutils-libelf-0.176-5.el7.i686.rpm libseccomp-2.3.1-4.el7.x86_64.rpm setools-libs-3.3.8-4.el7.x86_64.rpm elfutils-libelf-0.176-5.el7.x86_64.rpm libselinux-2.5-15.el7.i686.rpm systemd-219-78.el7.x86_64.rpm elfutils-libs-0.176-5.el7.i686.rpm libselinux-2.5-15.el7.x86_64.rpm systemd-libs-219-78.el7.i686.rpm elfutils-libs-0.176-5.el7.x86_64.rpm libselinux-python-2.5-15.el7.x86_64.rpm systemd-libs-219-78.el7.x86_64.rpm gcc-4.8.5-44.el7.x86_64.rpm libselinux-utils-2.5-15.el7.x86_64.rpm systemd-sysv-219-78.el7.x86_64.rpm glibc-2.17-317.el7.i686.rpm libsemanage-python-2.5-14.el7.x86_64.rpm xz-libs-5.2.2-1.el7.i686.rpm glibc-2.17-317.el7.x86_64.rpm libsepol-2.5-10.el7.i686.rpm zlib-1.2.7-18.el7.i686.rpm glibc-common-2.17-317.el7.x86_64.rpm libstdc++-4.8.5-44.el7.i686.rpm glibc-devel-2.17-317.el7.x86_64.rpm libstdc++-4.8.5-44.el7.x86_64.rpm
-
For downloading
docker-composelibrary, run the following command indocker-cedirectory:Bashcurl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-Linux-x86_64 -o docker-compose
it will download the packagedocker-composeindocker-cedirectory -
Use the following commands to pack the rpm packages of
docker-ceanddocker-compose.Bashtar cf docker-ce.offline.tar *
Transferring Binaries:
-
Copy the the
docker-ce.offline.tarto the destination machine where internet is restricted withftpor any other befitting method.Following steps are to be carried out on the machine where the internet is restricted.
-
Navigate to the destination machine (where internet access is restricted) and untar the
docker-ce.offline.tarfile by using the following command.Bashtar xf docker-ce.offline.tar
-
Use the command
rpm -ivh --replacepkgs --replacefiles *.rpmto installdocker-ce.Bashrpm -ivh --replacepkgs --replacefiles *.rpm
-
All the binaries will be installed. Now to enable and start the
docker-ce, run the following command.Bashsystemctl enable docker systemctl start docker
-
Now move the
docker-composebinary to location /usr/local/binand give it executable permission.Bashsudo mv docker-compose /usr/local/bin/ sudo chmod +x /usr/local/bin/docker-compose
-
You can verify if the docker and docker-compose have been installed or not by running the following command.
docker version
Docker version 19.03.13, build 4484c46d9d
docker-compose --version
docker-compose version 1.27.4, build 40524192
That's it. You now have docker-ce and docker-compose running on your offline machine.