Docker离线安装

1、mkdir /opt/docker/

2、vim /opt/docker/docker.service

bash 复制代码
[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

3、vim /opt/docker/install.sh

bash 复制代码
#!/bin/sh
echo '解压tar包...'
tar -xvf $1
echo '将docker目录移到/usr/bin目录下...'
cp docker/* /usr/bin/
echo '将docker.service 移到/etc/systemd/system/ 目录...'
cp docker.service /etc/systemd/system/
echo '添加文件权限...'
chmod +x /etc/systemd/system/docker.service
echo '重新加载配置文件...'
systemctl daemon-reload
echo '启动docker...'
systemctl start docker
echo '设置开机自启...'
systemctl enable docker.service
echo 'docker安装成功...'
docker -v

4、cp docker-20.10.23.tgz /opt/docker/ 【自己下载离线包】

5、vi /opt/docker/uninstall.sh

bash 复制代码
#!/bin/sh
echo '删除docker.service...'
rm -f /etc/systemd/system/docker.service
echo '删除docker文件...'
rm -rf /usr/bin/docker*
echo '重新加载配置文件'
systemctl daemon-reload
echo '卸载成功...'

6、

cd /opt/docker/

sh install.sh docker-20.10.23.tgz

7、vi /etc/docker/daemon.json

bash 复制代码
{
 "registry-mirrors" : [
   "https://mirror.ccs.tencentyun.com",
   "http://registry.docker-cn.com",
   "http://docker.mirrors.ustc.edu.cn",
   "http://hub-mirror.c.163.com"
 ],
 "insecure-registries" : [
   "registry.docker-cn.com",
   "docker.mirrors.ustc.edu.cn"
 ],
 "debug" : true,
 "experimental" : true
}

8、

systemctl restart docker.service

systemctl status docker

docker version

相关推荐
Liudef063 小时前
使用Docker部署MongoDB
mongodb·docker·容器
ZHOU_WUYI5 小时前
React与Docker中的MySQL进行交互
mysql·react.js·docker
Will_11305 小时前
如何实现k8s高可用
运维·docker·容器
编程、小哥哥5 小时前
互联网大厂Java面试场景:从缓存到容器化的技术问答
redis·docker·微服务·kubernetes·spring security·java面试·gitlab ci
luck_me56 小时前
基于 Kubernetes 部署容器平台kubesphere
云原生·容器·kubernetes
小白要努力sgy6 小时前
深入理解Docker和K8S
docker·kubernetes
青春不流名7 小时前
ctr查看镜像
docker
意倾城7 小时前
Docker 网络
docker·容器
Johny_Zhao7 小时前
AI+自动化测试系统方案:网络设备与网络应用智能测试
linux·网络·人工智能·python·网络安全·docker·ai·信息安全·云计算·ansible·shell·cisco·huawei·系统运维·itsm·华三·deepseek
_Meilinger_9 小时前
碎片笔记|PromptStealer复现要点(附Docker简单实用教程)
docker·huggingface·tmux·promptstealer·hf-mirror