docker-ce离线安装

docker-ce提供了常用的linux发行版的安装方式,但是离线安装很多时候仍然是一个需要,这篇文章介绍了如何在centos上使用离线安装包进行docker-ce版本的安装,此方式适用于大部分docker离线安装包的安装方式。

操作系统:

rhel7系列 内核版本大于3.1的redhat衍生版都可以

安装的需要过程及步骤:

Step 1 下载docker-ce的离线安装包
Step 2 解压出docker目录
Step 3 将docker目录下的内容拷贝到/usr/bin下并设置权限
Step 4 设置docker的systemd设定文件-
Step 5 设定docker的开机启动
Step 6 启动docker
Step 7 确认版本

安装脚本:

安装脚本 https://github.com/liumiaocn/easypack/blob/master/docker/install-docker.sh

安装说明:

下载离线安装包,然后将文件名作为参数传给安装脚本即可:
脚本内容:
https://github.com/liumiaocn/easypack/blob/master/docker/install-docker.sh

脚本具体内容:

#!/bin/sh

usage(){
  echo "Usage: $0 FILE_NAME_DOCKER_CE_TAR_GZ"
  echo "       $0 docker-17.09.0-ce.tgz"
  echo "Get docker-ce binary from: https://download.docker.com/linux/static/stable/x86_64/"
  echo "eg: wget https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz"
  echo ""
}
SYSTEMDDIR=/usr/lib/systemd/system
SERVICEFILE=docker.service
DOCKERDIR=/usr/bin
DOCKERBIN=docker
SERVICENAME=docker

if [ $# -ne 1 ]; then
  usage
  exit 1
else
  FILETARGZ="$1"
fi

if [ ! -f ${FILETARGZ} ]; then
  echo "Docker binary tgz files does not exist, please check it"
  echo "Get docker-ce binary from: https://download.docker.com/linux/static/stable/x86_64/"
  echo "eg: wget https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz"
  exit 1
fi

echo "##unzip : tar xvpf ${FILETARGZ}"
tar xvpf ${FILETARGZ}
echo

echo "##binary : ${DOCKERBIN} copy to ${DOCKERDIR}"
cp -p ${DOCKERBIN}/* ${DOCKERDIR} >/dev/null 2>&1
which ${DOCKERBIN}

echo "##systemd service: ${SERVICEFILE}"
echo "##docker.service: create docker systemd file"
cat >${SYSTEMDDIR}/${SERVICEFILE} <

创建脚本文件并下载docker-ce离线包并案场安装:

[root@nginx ~]#  vim install-docker.sh
[root@nginx ~]# chmod +x install-docker.sh 
[root@nginx ~]# ll install-docker.sh 
-rwxr-xr-x. 1 root root 63767 9月  30 10:51 install-docker.sh
[root@nginx ~]# curl -O https://download.docker.com/linux/static/stable/x86_64/docker-18.06.1-ce.tgz 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 41.8M  100 41.8M    0     0  3229k      0  0:00:13  0:00:13 --:--:-- 3779k
[root@nginx ~]# ll install-docker.sh docker-18.06.1-ce.tgz 
-rw-r--r--. 1 root root 43831680 9月  30 10:54 docker-18.06.1-ce.tgz
-rwxr-xr-x. 1 root root    63767 9月  30 10:51 install-docker.sh
[root@nginx ~]# ./install-docker.sh docker-18.06.1-ce.tgz 2>&1 |tee install.log
##unzip : tar xvpf docker-18.06.1-ce.tgz
docker/
docker/docker-containerd
docker/docker-proxy
docker/docker
docker/docker-runc
docker/dockerd
docker/docker-containerd-ctr
docker/docker-containerd-shim
docker/docker-init

##binary : docker copy to /usr/bin
/usr/bin/docker
##systemd service: docker.service
##docker.service: create docker systemd file

##Service status: docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: http://docs.docker.com
##Service restart: docker
##Service status: docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 日 2018-09-30 11:14:59 CST; 62ms ago
     Docs: http://docs.docker.com
 Main PID: 9280 (dockerd)
    Tasks: 23
   Memory: 89.3M
   CGroup: /system.slice/docker.service
           ├─9280 /usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --selinux-enabled=false --log-opt max-size=1g
           └─9287 docker-containerd --config /var/run/docker/containerd/containerd.toml

9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.090072348+08:00" level=error msg="Failed to start container e35a8642c79ef841a8b2afbddcbdf2400858a797a8f8bc1d9dac9263d3e69b1a: no such runtime 'docker-runc'"
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.222990972+08:00" level=error msg="6fc5ae351408243c4e2cc4206b0cd73601ad0d6ef9925305bd7116121f588470 cleanup: failed to delete container from containerd: no such container"
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.223067672+08:00" level=error msg="Failed to start container 6fc5ae351408243c4e2cc4206b0cd73601ad0d6ef9925305bd7116121f588470: no such runtime 'docker-runc'"
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.223094046+08:00" level=info msg="Loading containers: done."
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.332570472+08:00" level=info msg="Docker daemon" commit=e68fc7a graphdriver(s)=overlay2 version=18.06.1-ce
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.334084762+08:00" level=info msg="Daemon has completed initialization"
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.412387899+08:00" level=warning msg="Could not register builder git source: failed to find git binary: exec: \"git\": executable file not found in $PATH"
9月 30 11:14:59 nginx systemd[1]: Started Docker Application Container Engine.
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.437300918+08:00" level=info msg="API listen on /var/run/docker.sock"
9月 30 11:14:59 nginx dockerd[9280]: time="2018-09-30T11:14:59.450346128+08:00" level=info msg="API listen on [::]:4243"
##Service enabled: docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
## docker version
Client:
 Version:           18.06.1-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        e68fc7a
 Built:             Tue Aug 21 17:20:43 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server:
 Engine:
  Version:          18.06.1-ce
  API version:      1.38 (minimum version 1.12)
  Go version:       go1.10.3
  Git commit:       e68fc7a
  Built:            Tue Aug 21 17:28:38 2018
  OS/Arch:          linux/amd64
  Experimental:     false

所有的docker-ce历史二进制包下载地址:

https://download.docker.com/linux/static/stable/x86_64/

你可能感兴趣的:(Linux笔记)