服務器系統:Ubuntu Server 18.04.2 64bit
1 安裝docker:
1.1 在線安裝
1.# yum install docker
1.2 離線安裝 https://download.csdn.net/download/qq_27106141/90477700
1.# docker-18.03.1-ce.tgz
1.2.1 解壓
tar -xzvf docker-18.03.1-ce.tgz
1.2.2 將解壓出來的docker文件內容移動到 /usr/bin/ 目錄下
cp docker/* /usr/bin/
1.2.3 docker注冊為service
編輯/usr/lib/systemd/system/docker.service即可使用service docker restart/stop 等操作來啟停docker
vi /usr/lib/systemd/system/docker.service
復制以下代碼黏貼到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
1.2.4 啟動 添加文件權限并啟動docker
1.# chmod +x /usr/lib/systemd/system/docker.service
2.# systemctl daemon-reload
3.# systemctl start docker
4.# systemctl enable docker.service
1.2.5 驗證
1.# systemctl status docker
2.# docker -v
3.# docker images
4.# docker ps -a
5.# docker info
1.3 使用docker
1.3.1 啟動docker
1.設置docker開機啟動
2.# systemctl enable docker
3.啟動docker
4.# systemctl start docker
1 卸載docker:
yum remove docker-ce
rm -rf /var/lib/docker