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

相关推荐
2501_941148151 小时前
AI与大数据:推动智慧城市发展的双引擎
eureka
2501_941143733 小时前
5G时代的网络安全挑战与解决方案:守护数字未来
eureka
一夜空中最亮的星一5 小时前
【Linux】ubuntu24.04 安装docker
linux·docker·eureka
炸裂狸花猫5 小时前
开源域名证书工具 - cert-manager
云原生·容器·kubernetes·开源·cert-manager
会飞的小蛮猪5 小时前
Ubuntu24.04基于Docker部署K8s(使用私服部署)
经验分享·docker·云原生·容器·kubernetes
2501_941145858 小时前
微服务链路追踪与分布式调用可观测性在高并发优化实践经验分享
eureka
weixin_436525078 小时前
使用 idea 命令行构建 Docker 镜像并部署到云服务器
linux·docker·github
2501_941144429 小时前
物联网与智能家居:改变生活方式的数字化革命
eureka
2501_9411426410 小时前
云原生与Serverless架构在高并发互联网系统中的设计优化与工程实践经验分享
eureka
h***015410 小时前
Docker启动安装nacos(详情讲解,全网最细)
运维·docker·容器