codeforces div3 #776
阿新 • • 發佈:2022-03-09
Docker安裝
1、環境安裝
此處在Centos7進行安裝,可以使用以下命令檢視CentOS版本(別的系統可能無法使用)
lsb_release -a
在 CentOS 7安裝docker要求系統為64位、系統核心版本為 3.10 以上,可以使用以下命令檢視
uname -r
2、用yum源安裝
2.1 檢視是否已安裝docker列表
yum list installed | grep docker
2.2 安裝docker
yum -y install docker
-y表示不詢問安裝,直到安裝成功,安裝完後再次檢視安裝列表
2.3 啟動docker
systemctl start docker
2.4 檢視docker服務狀態
systemctl status docker
如果報錯可能是缺少docker.server檔案的問題
3、離線安裝模式
3.1 安裝包官方地址:https://download.docker.com/linux/static/stable/x86_64/
可以先下載到本地,然後通過ftp工具上傳到伺服器上,或者在伺服器上使用命令下載
wget https://download.docker.com/linux/static/stable/x86_64/docker-18.06.3-ce.tgz
3.2 解壓
tar -zxvf docker-18.06.3-ce.tgz
3.3 將解壓出來的docker檔案複製到 /usr/bin/ 目錄下
cp docker/* /usr/bin/
3.4 在/etc/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 --selinux-enabled=false --insecure-registry=127.0.0.1 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
此處的--insecure-registry=127.0.0.1(此處改成你私服ip)設定是針對有搭建了自己私服Harbor時允許docker進行不安全的訪問,否則訪問將會被拒絕。
3.5 啟動docker
給docker.service檔案新增執行許可權
chmod +x /etc/systemd/system/docker.service
重新載入配置檔案(每次有修改docker.service檔案時都要重新載入下)
systemctl daemon-reload
啟動
systemctl start docker
設定開機啟動
systemctl enable docker.service
檢視docker服務狀態
systemctl status docker
上圖表示docker已安裝成功