下載Docker并安裝
docker包下載地址
#下載docker-20.10.0包
https://download.docker.com/linux/static/stable/x86_64/docker-20.10.0.tgz
#上傳到Centos系統(tǒng)/data/目錄,如
scp docker-20.10.0.tgz root@192.168.0.5:/data/
#進(jìn)入data目錄,解壓docker包
cd /data
tar -zxvf docker-20.10.0.tgz
#將解壓出來的docker文件內(nèi)容移動到 /usr/bin/ 目錄下
cp docker/* /usr/bin/
#查看docker版本
docker version
#查看docker信息
docker info
配置Docker開機自啟動服務(wù)
#添加docker.service文件
vi /etc/systemd/system/docker.service
#按i插入模式,復(fù)制如下內(nèi)容:
[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
#添加文件可執(zhí)行權(quán)限
chmod +x /etc/systemd/system/docker.service
#重新加載配置文件
systemctl daemon-reload
#啟動Docker
systemctl start docker
#查看docker啟動狀態(tài)
systemctl status docker
#查看啟動容器
docker ps
#設(shè)置開機自啟動
systemctl enable docker.service
#查看docker開機啟動狀態(tài) enabled:開啟, disabled:關(guān)閉
systemctl is-enabled docker.service