centos安裝最新版的docker-ce(二進制安裝)

centos安裝最新版的docker-ce(二進制安裝)

本文轉自於https://www.jianshu.com/p/87a84097e635 


在centos上安裝過docker的都知道,yum install docker ,這種方式安裝的docker,最新版的centos系統上,版本應該是1.13.1,而目前最新版的docker到了18.03.0了。那麼怎麼安裝最新版的docker-ce呢?

1、系統要求

Linux操作系統內核要不低於3.10,並且要支持systemd。

2、下載最新版的docker

Docker官網下載地址:https://download.docker.com/linux/static/stable/x86_64/

上面列出了docker-ce版本,根據自己需要下載對應版本的docker-ce.
Docker官網下載地址:https://download.docker.com/linux/static/stable/x86_64/

image.png

我下載的是18.03.0版本。

3、安裝部署方式說明

整個安裝部署過程大致可分爲將介質解壓出docker目錄、將可執行文件copy到/usr/bin目錄並設置權限、設置docker的systemd設定文件、設定docker服務開機啓動等。
方便的是,已經有志願者將所有安裝命令整理成一個腳本,直接下載下來執行即可。
腳本下載地址:

https://github.com/liumiaocn/easypack/blob/master/docker/install-docker.sh

#!/bin/shusage(){  echo "Usage: $0 FILE_NAME_DOCKER_CE_TAR_GZ"
  echo "       $0 docker-18.03.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-18.03.0--ce.tgz"
  echo ""}
SYSTEMDDIR=/usr/lib/systemd/system
SERVICEFILE=docker.service
DOCKERDIR=/usr/bin
DOCKERBIN=docker
SERVICENAME=dockerif [ $# -ne 1 ]; then
  usage  exit 1else
  FILETARGZ="$1"fiif [ ! -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-18.03.0--ce.tgz"
  exit 1fiecho "##unzip : tar xvpf ${FILETARGZ}"tar xvpf ${FILETARGZ}echoecho "##binary : ${DOCKERBIN} copy to ${DOCKERDIR}"cp -p ${DOCKERBIN}/* ${DOCKERDIR} >/dev/null 2>&1which ${DOCKERBIN}echo "##systemd service: ${SERVICEFILE}"echo "##docker.service: create docker systemd file"cat >${SYSTEMDDIR}/${SERVICEFILE} <<EOF
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \
                -H tcp://0.0.0.0:4243 \
                -H unix:///var/run/docker.sock \
                --selinux-enabled=false \
                --log-opt max-size=1g
ExecReload=/bin/kill -s HUP $MAINPID# Having non-zero Limit*s causes performance problems due to accounting overhead# in the kernel. We recommend using cgroups to do container-local accounting.LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity# Uncomment TasksMax if your systemd version supports it.# Only systemd 226 and above support this version.#TasksMax=infinityTimeoutStartSec=0# set delegate yes so that systemd does not reset the cgroups of docker containersDelegate=yes# kill only the docker process, not all processes in the cgroupKillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOFecho ""systemctl daemon-reloadecho "##Service status: ${SERVICENAME}"systemctl status ${SERVICENAME}echo "##Service restart: ${SERVICENAME}"systemctl restart ${SERVICENAME}echo "##Service status: ${SERVICENAME}"systemctl status ${SERVICENAME}echo "##Service enabled: ${SERVICENAME}"systemctl enable ${SERVICENAME}echo "## docker version"docker version

4、安裝部署

1、上傳文件並設置執行權限,將腳本和文件放在同一級目錄。

chmod +x install-docker.sh  # 授予可執行權限

2、執行安裝命令

./install-docker.sh  docker-18.03.0-ce.tgz
安裝過程最後,腳本會執行docker version命令來顯示docker的版本。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章