Cloud Native 4 min read

How to Install and Uninstall Docker Offline on CentOS 7

This guide walks through downloading the Docker 20.10.7 offline package, extracting it on a CentOS 7 host, configuring a systemd service, starting Docker, verifying the installation, and then fully removing Docker and its service files when needed.

The Dominant Programmer
The Dominant Programmer
The Dominant Programmer
How to Install and Uninstall Docker Offline on CentOS 7

When a CentOS 7 server cannot reach the internet, Docker must be installed from an offline package.

First, download the Docker static binaries from https://download.docker.com/linux/static/stable/x86_64/ and select version 20.10.7 . Transfer the docker-20.10.7.tgz file to the target server.

On the server, extract the archive: tar -zvxf docker-20.10.7.tgz Copy the extracted binaries to the system binary directory: cp docker/* /usr/bin/ Create a docker.service file with the following content:

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

Copy the file to /etc/systemd/system/, make it executable, reload the systemd daemon, start Docker, and verify the version:

cp docker.service /etc/systemd/system/
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
docker version

To uninstall Docker, stop the service, remove the service file and binaries, and reload the daemon:

systemctl stop docker
rm -f /etc/systemd/system/docker.service
rm -rf /usr/bin/docker*
systemctl daemon-reload
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DockerContainer Runtimesystemdcentos7offline installation
The Dominant Programmer
Written by

The Dominant Programmer

Resources and tutorials for programmers' advanced learning journey. Advanced tracks in Java, Python, and C#. Blog: https://blog.csdn.net/badao_liumang_qizhi

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.