linux离线安装docker

年爸 1年前 ⋅ 608 阅读

1.下载最新版Docker安装包

https://download.docker.com/linux/static/stable/x86_64/

2.上传至服务器,解压

tar -xvf docker-24.0.7.tgz

3.将解压出来的docker文件夹,复制到/usr/bin目录下

cp docker/* /usr/bin/

4.将docker注册成系统服务

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

5.增加可执行权限

chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload 

6.设置开机启动、启动、测试

# 开机启动
systemctl enable docker.service
# 启动
systemctl start docker
# 测试
docker --version

7. 排错

如果遇到:docker: command not found;则需要配置环境变量

vim ~/.bashrc 
export PATH="/usr/bin/docker:$PATH"

 

 

 


全部评论: 0

    我有话说: