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

相关推荐
wydydgh32 分钟前
docker 升级步骤
运维·docker·容器
2401_840192271 小时前
在k8s中,客户端访问服务的链路流程,ingress--->service--->deployment--->pod--->container
云原生·容器·kubernetes
jonssonyan3 小时前
稳了,搭建Docker国内源图文教程
运维·docker·容器
福大大架构师每日一题3 小时前
16.2 k8s容器基础资源指标讲解
云原生·容器·kubernetes·prometheus
工业甲酰苯胺4 小时前
k8s 中的 Ingress 简介
云原生·容器·kubernetes
周湘zx5 小时前
k8s中的存储
linux·运维·云原生·容器·kubernetes
[听得时光枕水眠]5 小时前
【Docker】Docker上安装MySql8和Redis
运维·docker·容器
神秘的土鸡6 小时前
Linux中Docker容器构建MariaDB数据库教程
linux·运维·服务器·数据库·docker·mariadb
攸攸太上8 小时前
Docker学习
java·网络·学习·docker·容器
Sylvan Ding8 小时前
Docker+PyCharm远程调试&环境隔离解决方案
docker·容器·pycharm