Docker offline installation

Source: Internet
Author: User
Tags curl prepare
background

In a recent privatization deployment project, the project's overall programme is based on Docker. Considering that the customer's operating environment may not be able to connect to the public network, it is necessary to make a Docker offline installation. The entire offline installation is divided into three parts: 1 Prepare Docker offline installation package, 2 Docker offline source configuration, 3 offline installation Docker prepare Docker offline installation package

Only Linux and its distribution servers are currently considered. Docker requirements for machines and operating systems: Kernel version 3.10 and its operating system digits are 64-bit CPU architectures for x86_64 or AMD64 (currently there are other support) kernels open and support Cgroup and namespaces

To put it simply, the commonly used CentOS 7 and above, Ubuntu 14 and above, Fedora 24 and above, Debian 8 and above, and Raspbian. This section can refer specifically to [1]. This is the official Docker online installation script, the content of this article is the main reference to this script.

For different operating systems, different architectures, the need for Docker installation package is different, so to separate processing. The current mainstream package management tools are Apt-get and yum, which correspond to the Ubuntu\debian and Centos\fedora series operating systems respectively. Regardless of which package management tool, the basic idea is to download the Docker installation package and its dependencies on the downloaded installation package make local source prepare local source configuration file

For Apt-get, you can execute the following script, which extracts from the reference link [1]. For the explanation of the process you can refer to the link [2]

#!/bin/sh lsb_dist= "ubuntu" dist_version= "xenial" # 14-trusty 16-xenial 17-zesty "Download_url=" . Com/docker-ce "download_dir="/home/work/docker-packages/$lsb _dist-$dist _version "Set-e apt_repo=" Deb [arch=$ (dpkg --print-architecture)] $DOWNLOAD _url/linux/$lsb _dist $dist _version Stable "if [!-X" $DOWNLOAD _dir "]; Then Mkdir-p "$DOWNLOAD _dir" fi apt-get update-qq >/dev/null apt-get install-y-qq Apt-transport-https Ca-certi Ficates Curl Dpkg-dev >/dev/null curl-fssl "$DOWNLOAD _url/linux/$lsb _dist/gpg" | Apt-key Add->/dev/null echo "$apt _repo" >/etc/apt/sources.list.d/docker.list if ["$lsb _dist" = "Debian"] & & ["$dist _version" = "wheezy"];  Then Sed-i "/deb-src.*download\.docker/d"/etc/apt/sources.list.d/docker-ce.list fi # Download only Docker and dependent installation packages Apt-get update -QQ >/dev/null apt-get--download-only-o dir::cache= "./"-O dir::cache::archives= $DOWNLOAD _dir, install-y--no-insta Ll-recommends docker-ce >/dev/null # for installation packageIndexing to facilitate subsequent loading for local source install touch $DOWNLOAD _dir/packages.gz dpkg-scanpackages $DOWNLOAD _dir/dev/null |
 gzip > $DOWNLOAD _dir/packages.gz

When I was making, for the generated packages.gz, adjust the filename of each software, leaving only the software name, do not keep the previous directory path. You can use the SED command specifically.

For Yum, the following script can be executed, and the script is also extracted from the reference link [1]. For the explanation of the process you can refer to the link [3]

#!/bin/sh

lsb_dist= "CentOS"
dist_version= "7"

download_url= "Https://mirrors.aliyun.com/docker-ce"
download_dir= "/home/work/docker-packages/$lsb _dist-$dist _version"

set-e yum_repo=
"$DOWNLOAD _url/ linux/$lsb _dist/docker-ce.repo "

if [!-X" $DOWNLOAD _dir "]; then
    mkdir-p" $DOWNLOAD _dir "
fi

Download only Docker and dependent installation packages
Yum-config-manager--add-repo $yum _repo yum makecache yum install--downloadonly
- downloaddir= $DOWNLOAD _dir docker-ce

# Set up an index for the installation package to facilitate subsequent loading for local source installation
Createrepo $DOWNLOAD _dir
Prepare Docker offline source configuration

Copy the contents of the installer package (\ $lsb _dist-$dist _version) to the target machine, such as a unified/home/work/docker-packages directory. Based on this path:

For the Apt-get system, the off-line source configuration file is Docker-ce.list, the contents are as follows

Deb [Trusted=yes] file:/home/work/docker-packages./

For the Yum system, the off-line source configuration file is Docker-ce.repo, the contents are as follows

[Local_docker_yum]
Name=local Docker Yum Repository
baseurl=file:///home/work/docker-packages/
enabled=1
Offline installation Docker

For Apt-get, copy the offline source profile docker-ce.list to the/ETC/APT/SOURCES.LIST.D directory. If the computer is not networked, rename the/etc/apt/sources.list file first, then execute Apt-get Update, and then rename the/etc/apt/sources.list back. If this is not the case, the network may fail to complete the update when Apt-get update.
Finally, execute Apt-get install Docker-ce

For yum, copy the offline source profile Docker-ce.repo to the/etc/yum.repos.d/directory. If the computer cannot be networked, rename the other configuration files in the/etc/yum.repos.d/directory first, then execute Yum makecache, and then change the file that you just renamed back. The reasons for doing so are ditto.
Finally, execute yum install Docker-ce

Reference Links:
[1]https://get.docker.com/
[2]http://blog.csdn.net/candcplusplus/article/details/52156324
[3]http://www.cnblogs.com/zzyyxxjc/p/4346975.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.