centos7靜態二進制文件離線安裝docker

centos7靜態二進制文件離線安裝

官方參考:https://docs.docker.com/install/linux/docker-ce/binaries/#install-static-binaries
官方安裝參考真的踩過很多坑。。。

1. 下載靜態二進制文件

docker下載地址:https://download.docker.com,根據需要下載相應的docker文件。
x86服務器64位linux穩定版靜態二進制文件下載地址:https://download.docker.com/linux/static/stable/x86_64,下載需要版本的.tgz。

2. 安裝

docker是先要用root用戶進行安裝的

$ tar xzvf /path/to/<FILE>.tar.gz
$ chmod 755 -R docker/
$ cp docker/* /usr/bin/

3. 把docker註冊成服務

$ vi /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

開啓docker服務

$ systemctl enable docker
$ systemctl start docker

4. 驗證

通過查看docker的版本命令,驗證docker 是否啓動成功

$ docker version

5.配置非root用戶操作docker

前提要在docker啓動的情況下,創建docker用戶,設置密碼

$ useradd docker
$ passwd docker
# 理論上創建了docker用戶,會默認在docker組,但是爲了防止萬一,手動再創建docker組
$ groupadd docker
$ gpasswd -a docker docker
# 重啓docker
$ systemctl restart docker
# 驗證
$ docker version
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章