Skip to main content
Skip table of contents

Setup Docker Engine on Centos Offline

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:

  1. A Linux virtual machine with internet access to download the binaries of Docker Engine.
  2. 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.

  1. Use the following command to set up the docker stable repository.

    curl -sSL -o /etc/yum.repos.d/docker-ce.repo
  2. Use the yum list docker-ce --showduplicates | sort -r to list all available docker-ce packages.

     yum 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
  3. Use yum deplist docker-ce-17.12.0.ce-1.el7.centos to list dependency packages.

     yum deplist docker-ce-18.03.1.ce-1.el7.centos
    Loaded plugins: fastestmirror
    Loading mirror speeds from cached hostfile
     * base:
     * extras:
     * updates:
    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
       provider: device-mapper-libs.x86_64 7:1.02.170-6.el7
       provider: device-mapper-libs.x86_64 7:1.02.170-6.el7
       provider: device-mapper-libs.x86_64 7:1.02.170-6.el7
       provider: glibc.x86_64 2.17-317.el7
       provider: glibc.x86_64 2.17-317.el7
       provider: libtool-ltdl.x86_64 2.4.2-22.el7_3
       provider: glibc.x86_64 2.17-317.el7
       provider: glibc.x86_64 2.17-317.el7
       provider: glibc.x86_64 2.17-317.el7
      dependency: libseccomp >= 2.3
       provider: libseccomp.x86_64 2.3.1-4.el7
  4. The dependencies for docker and docker-compose are already figured out. Next, we need to yumdownload the required libraries. Let’s make a directory named docker-ce and use  yumdownloader --resolve  to resolve the dependencies.

     mkdir 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 yumdownloader is not present, download it by running: 

    yum install yum-utils

  5. If you ls in docker-ce, you would see plenty of .rpm files downloaded in the directory.

    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                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
  6. For downloading docker-compose library, run the following command in docker-ce directory:

     curl -L -o docker-compose

    it will download the package docker-compose in docker-ce directory

  7. Use the following commands to pack the rpm packages of docker-ce and docker-compose.

    tar cf docker-ce.offline.tar *

Transferring Binaries:

  1. Copy the the docker-ce.offline.tar to the destination machine where internet is restricted with ftp or any other befitting method. 

    Following steps are to be carried out on the machine where the internet is restricted.

  2. Navigate to the destination machine (where internet access is restricted) and untar the docker-ce.offline.tar file by using the following command.

    tar xf docker-ce.offline.tar
  3. Use the command rpm -ivh --replacepkgs --replacefiles *.rpm to install docker-ce.

    rpm -ivh --replacepkgs --replacefiles *.rpm 
  4. All the binaries will be installed. Now to enable and start the docker-ce, run the following command.

    systemctl enable docker
    systemctl start docker
  5. Now move the docker-compose binary to location /usr/local/bin and give it executable permission.

    sudo mv docker-compose /usr/local/bin/
    sudo chmod +x /usr/local/bin/docker-compose
  6.  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.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.