linux下docker安裝
阿新 • • 發佈:2022-03-04
docker下載地址
https://download.docker.com/linux/static/stable/x86_64/
下載安裝
wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.6.tgz
tar -zvxf docker-19.03.6.tgz
cp docker/* /usr/bin/
直接執行
/usr/bin/dockerd
demon模式執行,並儲存日誌
nohup /usr/bin/dockerd >/docker.log 2>&1 &
systemctl執行 sudo vim /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 ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target
設定許可權許可權為可執行
chmod +x /etc/systemd/system/docker.service
新增阿里雲映象j
cat > /etc/docker/daemon.json << EOF
{
"registry-mirrors": ["https://zxnkv11f.mirror.aliyuncs.com"]
}
EOF
常用命令
systemctl daemon-reload //過載配置檔案
systemctl start docker //啟動Docker
systemctl stop docker //關閉docker
systemctl restart docker //重啟docker
systemctl enable docker.service //設定開機自啟
systemctl status docker //檢視Docker狀態
很多時候在我們掛載磁碟後不想用docker預設目錄 可 -g 修改目錄 (docker 預設目錄在/var/lib/docker下,包括 pull下來的映象都在該目錄下)
ExecStart修改為:
ExecStart=/usr/bin/dockerd -g /xiaobo/docker
指令碼安裝docker
#/bin/bash wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.6.tgz tar -zvxf docker-19.03.6.tgz cp docker/* /usr/bin/ cat > /etc/systemd/system/docker.service << EOF [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=/usr/bin/dockerd ExecReload=/bin/kill -s HUP $MAINPID LimitNOFILE=infinity LimitNPROC=infinity TimeoutStartSec=0 Delegate=yes KillMode=process Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target EOF chmod +x /etc/systemd/system/docker.service mkdir -p /etc/docker/ cat > /etc/docker/daemon.json << EOF { "registry-mirrors": ["https://zxnkv11f.mirror.aliyuncs.com"] } EOF systemctl daemon-reload systemctl start docker systemctl enable docker.service systemctl status docker