1寿羞、先去官方下個壓縮包
下載地址:https://download.docker.com/linux/static/stable/x86_64/
我下載的是:docker-24.0.5.tgz
2抡柿、下載完成之后纳鼎,上傳服務(wù)器解壓并移動到usr/bin目錄下
tar zxf docker-24.0.5.tgz && mv docker/* /usr/bin/
3秸妥、進入 /etc/systemd/system/ 目錄,創(chuàng)建 docker.service 文件抗蠢,內(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 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP
# 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薛躬、添加執(zhí)行權(quán)限
chmod a+x /etc/systemd/system/docker.service
5、刷新docker.service文件
systemctl daemon-reload
6僧界、啟動docker
systemctl start docker
7侨嘀、設(shè)置dokcer開機啟動
systemctl enable docker
8、查看docker開機啟動狀態(tài)
systemctl is-enabled docker
9捂襟、添加path環(huán)境變量
vim /etc/profile
export PATH=$PATH:/usr/bin/docker
10咬腕、刷新環(huán)境變量
source /etc/profile
11、可以使用docker命令了
docker version
docker images