Install Docker offline on CentOS 7
-
Download the Docker installation package for CentOS 7:
https://download.docker.com/linux/static/stable/x86_64/
-
Upload the downloaded
docker-24.0.4.tgz
file to the CentOS 7 system. For example, it can be uploaded to/root
the directory. -
Unzip
docker-24.0.4.tgz
the file:tar -xf docker-24.0.4.tgz
-
Copy all the extracted Docker files to
/usr/bin/
the directory:cp docker/* /usr/bin/
-
Register Docker as a service, enter
/etc/systemd/system/
the directory, and createdocker.service
a file:vi /etc/systemd/system/docker.service
-
Copy the following content into
docker.service
the file. Replace192.168.3.10
with the IP address of your own server:[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=192.168.3.10 ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
-
Give
docker.service
the file execution permission:chmod 644 /etc/systemd/system/docker.service
-
Reload the systemd daemon to apply the changes:
systemctl daemon-reload
-
Start Docker and set it to start automatically at boot:
systemctl start docker systemctl enable docker
-
Test Docker to make sure it's working.
Uninstall Docker on CentOS 7
-
Cancel Docker's boot self-start:
systemctl disable docker
-
Delete the Docker service file:
rm -rf /etc/systemd/system/docker.service
-
Remove Docker related binaries:
rm -rf /usr/bin/containerd rm -rf /usr/bin/containerd-shim rm -rf /usr/bin/ctr rm -rf /usr/bin/runc rm -rf /usr/bin/docker*
-
Delete the Docker configuration file:
rm -rf /etc/docker/
-
If images or containers exist, delete them:
rm -rf /var/lib/docker
Extension: import image and run
If you want to run the image on a machine without an external network connection, take PaddleOCR as an example:
- On a machine connected to the Internet, download the PaddleOCR Docker image and its dependencies (version 1.6.server):
docker pull registry.cn-hongkong.aliyuncs.com/llapi/ppocr:1.6.server
- Save the Docker image and its dependencies as a tar file:
docker save -o ppocr_1.6.server.tar registry.cn-hongkong.aliyuncs.com/llapi/ppocr:1.6.server
-
Copy the Docker image file "ppocr_1.6.server.tar" to the target machine without external network connection.
-
Install Docker on the target machine.
-
Load the Docker image with the following command:
docker load -i ppocr_1.6.server.tar
- Run the PaddleOCR container:
docker run -itd --name ppocr -p 9000:9000 registry.cn-hongkong.aliyuncs.com/llapi/ppocr:1.6.server /bin/bash -c "sh /PaddleOCR/start.sh"
The PaddleOCR container version 1.6.server should now be running on the target machine with no external internet connection, and you can access it on port 9000. This concludes the tutorial