離線安裝 docker

我聽過發表於2020-07-25

1、基礎環境

作業系統:CentOS 7.8

docker 版本:18.06.1

2、docker 下載

2.1 官方地址

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

2.2 百度雲地址

連結:https://pan.baidu.com/s/1H-pDa9ZPh_fvi_t-x7KSGA  提取碼:sg7a

2.3 官方參考文件

https://docs.docker.com/engine/install/binaries/

3、docker 安裝

3.1 上傳解壓

[root@docker ~]# rz -E
rz waiting to receive.
[root@docker ~]# ls
anaconda-ks.cfg  docker-18.06.1-ce.tgz
[root@docker ~]# tar -xvf 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
[root@docker ~]# ls docker/
docker                  docker-containerd-shim  docker-proxy
docker-containerd       dockerd                 docker-runc
docker-containerd-ctr   docker-init

3.2 移動解壓檔案內容至 /usr/bin/ 目錄下

[root@docker ~]# cp docker/* /usr/bin/
[root@docker ~]# ls /usr/bin/docker*
/usr/bin/docker                 /usr/bin/docker-containerd-shim  /usr/bin/docker-proxy
/usr/bin/docker-containerd      /usr/bin/dockerd                 /usr/bin/docker-runc
/usr/bin/docker-containerd-ctr  /usr/bin/docker-init

3.3 將 docker 註冊為 service

[root@docker ~]# vim /etc/systemd/system/docker.service    #新建檔案,將下列配置新增至檔案
[Unit]

Description=Docker Application Container Engine

Documentation=https://docs.docker.com

After=network-online.target firewalld.service

Wants=network-online.target

[Service]

Type=notify

# the default is not to use systemd for cgroups because the delegate issues still

# exists and systemd currently does not support the cgroup feature set required

# for containers run by docker

ExecStart=/usr/bin/dockerd

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=infinity

TimeoutStartSec=0

# set delegate yes so that systemd does not reset the cgroups of docker containers

Delegate=yes

# kill only the docker process, not all processes in the cgroup

KillMode=process

# restart the docker process if it exits prematurely

Restart=on-failure

StartLimitBurst=3

StartLimitInterval=60s

 

[Install]

WantedBy=multi-user.target

3.4 啟動 docker

[root@docker ~]# chmod +x /etc/systemd/system/docker.service  #新增檔案許可權
[root@docker ~]# systemctl daemon-reload    #過載unit配置檔案
[root@docker ~]# systemctl start docker    /#啟動Docker
[root@docker ~]# systemctl enable docker.service    #設定開機自啟
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.

3.5 驗證

[root@docker ~]# systemctl status docker
 docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since 六 2020-07-25 17:23:24 CST; 28s ago
     Docs: https://docs.docker.com
 Main PID: 1707 (dockerd)
   CGroup: /system.slice/docker.service
           ├─1707 /usr/bin/dockerd
           └─1723 docker-containerd --config /var/run/docker/containerd/containerd.toml

7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.394502816+08:00" level=i...rpc
7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.394716555+08:00" level=i...rpc
7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.395095630+08:00" level=i...rpc
7月 25 17:23:23 docker dockerd[1707]: time="2020-07-25T17:23:23.395142000+08:00" level=i...t."
7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.082088050+08:00" level=i...ss"
7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.274261695+08:00" level=i...e."
7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.301752021+08:00" level=i...-ce
7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.302039079+08:00" level=i...on"
7月 25 17:23:24 docker systemd[1]: Started Docker Application Container Engine.
7月 25 17:23:24 docker dockerd[1707]: time="2020-07-25T17:23:24.406835353+08:00" level=i...ck"
Hint: Some lines were ellipsized, use -l to show in full.
[root@docker ~]# docker -v
Docker version 18.06.1-ce, build e68fc7a

 

相關文章