CentOS7 offline installation of docker ce and docker-compose

docker introduction

  • Simply put, virtualization, containerization, and consistency in each environment
  • Official definition: Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image, and then publish it to any popular Linux or Windows operating system machine, and also implement virtual change. Containers use a sandbox mechanism completely, and there will be no interfaces between them.

Application Scenario

  • All of our Spring Bootservices use dockerdeployment, and we use eclipse-temurin:11-jre-focalpackaged java services
  • Our customer's network environment is relatively complicated, and it is not allowed to connect to the external network. Generally, the docker service is not installed in the centos7 system, or the version is very low, and there is no available source in their own network to download or update.
  • We need to install the docker service and docker-compose in an offline environment
  • I tried to download and install several rpm packages required by docker-ce before, but found that the four or five packages were not enough. One of its rpm packages is associated with another, and the associated package may require other dependent packages, which feels a bit troublesome
  • After actually solving it, I found that the solution is surprisingly simple

deal with

  • The first is docker ce. The main trouble is that I don’t know how many dependent packages are needed. After searching, I found that Linux itself provides some methods for searching dependencies.
  • What I use here is that yumdownloader --resolve docker-ceit will automatically find the relevant dependencies and download them all
  • I found the centos7 image package, and imported it into a new system with virtualBox. In this relatively primitive and clean system, it is connected to the Internet. After executing this command, all dependencies will be downloaded.
mkdir ~/docker
cd ~/docker
yumdownloader --resolve docker-ce
tar czf ~/docker.tar.gz *
  • Copy docker.tar.gzthe dependent compressed package to a U disk, and then copy it to a machine at the customer site, use winscp to transfer it to the server, and execute the command to install it.
cd ~
mkdir docker
tar xf docker.tar.gz -C ~/docker
cd docker
rpm -ivh --replacefiles --replacepkgs *.rpm
systemctl enable docker.service
systemctl start docker.service
docker -v
  • You can see the docker version I installedDocker version 20.10.21, build baeda1f
  • docker-compose uses pre- downloaded
cd ~
mv docker-compose /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
  • You can see my docker-compose versiondocker-compose version 1.23.0, build c8524dc1
  • Now that the installation is complete, sometimes I find it difficult, just because I am not familiar with it, so I can't hold back. Be good at using search engines and learn from the wisdom of predecessors.
  • Questioning, searching, learning, summarizing, sharing, forming an open loop

Guess you like

Origin blog.csdn.net/u010882234/article/details/129033824