How to Install Docker and Docker-compose Offline on Linux (Using Ubuntu as an Example)
Nowadays, the biggest challenge for many domestic developers using Docker is installing Docker on a Linux server!
Rendering...
## Preface Nowadays, the biggest hurdle for many domestic developers when using Docker is: installing Docker on a Linux server! Today, I'm writing an article to document the detailed steps of an old dog installing Docker offline on an Ubuntu system. > Declaration: > > 1. This article uses `Ubuntu 22` as the system version; for other versions, please adapt accordingly. > 2. All commands in this article are executed under superuser privileges. If you are not using the `root` user, please add `sudo` yourself. > 3. This article mainly references a Zhihu article: [Docker Offline Installation Tutorial](https://zhuanlan.zhihu.com/p/578402141) ## Download Docker Offline Installation Package 1. Open the link: https://download.docker.com/linux/static/stable/ 2. Find the folder corresponding to your system architecture (the mainstream currently is `x86_64`, corresponding to `amd64`); 3. Find the `docker-xx.xx.x.tgz` file and start downloading; 4. After the download is complete, proceed with the installation preparation. > Tips: > > 1. `xx.xx.x` represents the version number. For example, the old dog chose `28.4.0`. Download as needed; if there are no special requirements, you can download the latest version. > 2. If you are unsure of your system architecture, you can try running commands like `arch` or `lsb_release -a` to check; ## Install Docker 1. Upload the previously downloaded file to the server (just create any empty directory); 2. Run the command to extract the file: `tar xvf docker-xx.xx.x.tgz` (change the filename to the one you downloaded); 3. Run the command to move the files: `cp docker/* /usr/bin`; 4. Run the command to create and edit the service script: `vim /etc/systemd/system/docker.service`; 5. Paste the following `docker.service` script into the file and save it; 6. Run the command to add execution permissions: `chmod +x /etc/systemd/system/docker.service`; 7. Run the command to reload system services: `systemctl daemon-reload`; 8. Run the command to set Docker to start on boot: `systemctl enable docker.service`; 9. Run the command to start Docker: `systemctl start docker`; 10. Run the command to check the Docker version: `docker -v`. After the above ten steps, if the Docker version is successfully output, for example: `Docker version 28.4.0, build d8eb465`, it indicates a successful installation! Below is the script needed for step five: ### docker.service Script ```sh [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 ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target ``` ## Download and Install Docker-Compose Installing Docker-Compose is much simpler: 1. Go to Github (`https://github.com/docker/compose/releases`) and find the version you need; 2. Download the executable file adapted for your system, for example: `docker-compose-linux-x86_64`; 3. Upload the downloaded file to the server; 4. Execute the command to move and rename the executable file: `cp -f ./docker-compose-linux-x86_64 /usr/local/bin/docker-compose`; 5. Grant execution permissions: `chmod +x /usr/local/bin/docker-compose`; 6. Done. If you need the file downloads mentioned in this article, you can go to my Yuanli Push to get them: [Docker Offline Package (x86_64-28.4.0)](https://dingdangdog.yuanlitui.com/a/a821)
Comments
Please login to view and post comments
Go to Login