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.
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.targetCopy 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 versionTo 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-reloadSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
