一棘脐、背景
由于公司內(nèi)部網(wǎng)絡(luò)原因斜筐,無法使用在線安裝Docker龙致;試了很多種離線安裝方式,由于Docker依賴了很多rpm顷链,要離線安裝必須得先安裝依賴(較為麻煩目代,遂放棄);最后使用二進(jìn)制方式安裝:把Docker注冊為服務(wù)
二嗤练、準(zhǔn)備
參考文檔:https://docs.docker.com/install/linux/docker-ce/binaries/#install-static-binaries
下載地址:https://download.docker.com/linux/static/stable/x86_64/
download.png
三榛了、安裝
1、解壓
$ tar xzvf /path/to/<FILE>.tar.gz
2煞抬、將二進(jìn)制文件移動(dòng)到可執(zhí)行文件路徑上的目錄中霜大,例如/usr/bin/。如果跳過此步驟革答,則必須在調(diào)用docker或dockerd命令時(shí)提供可執(zhí)行文件的路徑战坤。
$ cp docker/* /usr/bin/
3、啟動(dòng)Docker守護(hù)程序(此方式只是臨時(shí)啟動(dòng)残拐,重啟后還需要重新啟動(dòng)途茫,可跳過此步驟)
$ dockerd &
如果需要使用其他選項(xiàng)啟動(dòng)守護(hù)程序,請相應(yīng)地修改上述命令溪食,或者創(chuàng)建并編輯該文件/etc/docker/daemon.json 以添加自定義配置選項(xiàng)
3囊卜、將docker注冊為service
$ vim /etc/systemd/system/docker.service
將以下內(nèi)容拷貝到docker.service中
[Unit]
Description=Docker Application Container Engine
Documentation=[https://docs.docker.com](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
4、啟動(dòng)
# 賦予權(quán)限
$ chmod +x /etc/systemd/system/docker.service
# 重新加載
$ systemctl daemon-reload
#啟動(dòng)Docker
$ systemctl start docker
#設(shè)置開機(jī)自啟
$ systemctl enable docker.service
5错沃、檢查是否安裝成功
#查看Docker狀態(tài)
$ systemctl status docker
#查看Docker版本
$ docker -v