【Docker】Linux下離線安裝Docker18.06
阿新 • • 發佈:2021-01-29
技術標籤:Linux一名實施工程師的自我修養
1.下載介質
Docker下載連結
此處選擇的是18.06.03-ce.tgz
2.上傳並解壓
tar -xvf docker-18.06.3-ce.tgz
3.移動到bin目錄下
cp docker/* /usr/bin/
4. 新增docker配置檔案
[[email protected] 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
5.啟動docker
chmod 777 /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
systemctl enable docker.service
6.驗證啟動情況
docker ps #驗證docker是否正常啟動
[[email protected] docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[[email protected] docker]#
補充問題:
用非root使用者啟動docker時會需要進行授權,在docker ps時也提示沒許可權,解決方法,直接把普通使用者加到root組……
[[email protected] bin]# usermod -g root nrms
[[email protected] bin]# su nrms
[[email protected] bin]$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[[email protected] bin]$
報錯內容:
[[email protected] docker]$ systemctl daemon-reload
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
[[email protected] docker]$ systemctl start docker
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
[[email protected] docker]$ systemctl enable docker.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /etc/systemd/system/docker.service.
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Authenticating as: root
Password:
==== AUTHENTICATION COMPLETE ===
[[email protected] docker]$ docker
[[email protected] docker]$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.38/containers/json: dial unix /var/run/docker.sock: connect: permission denied
[[email protected] docker]$ exit
參考:
離線安裝docker-docker-18.06.1-ce.tgz
解決Ubuntu18.04啟動Docker“Got permission denied while trying to connect to the Docker daemon socket“問題
docker 許可權問題 Got permission denied while trying to connect to the Docker daemon socket at 。。。