https://download.docker.com/linux/static/stable/x86_64/
选择docker-20.10.24.tgz
tar -zxvf docker-20.10.24.tgz
cp docker/* /usr/bin/
cd /etc/systemd/system/
touch docker.service
注:以下内容中 --insecure-registry=192.168.3.10 此处改为你自己服务器ip。
vim 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
# 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 --selinux-enabled=false --insecure-registry=192.168.3.10
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
chmod 777 /etc/systemd/system/docker.service
• 注:每次修改docker.service这个文件时都要重新加载下。
systemctl daemon-reload
systemctl enable docker.service
systemctl status docker
docker -v
编辑 /etc/docker/目录下的daemon.json文件,将以下内容复制到daemon.json文件中,如下图:
vim /etc/docker/daemon.json
{"registry-mirrors": ["http://hub-mirror.c.163.com"]}
重启docker,使其daemon.json文件配置生效,如下图:
参考:https://blog.csdn.net/qq_20466211/article/details/108762800
#取消开机自启
systemctl disable docker
#取消注册文件
rm -rf /etc/systemd/system/docker.service
rm -rf /usr/bin/containerd
rm -rf /usr/bin/containerd-shim
rm -rf /usr/bin/ctr
rm -rf /usr/bin/runc
rm -rf /usr/bin/docker*
rm -rf /etc/docker/
rm -rf /var/lib/docker
内网环境没法pull镜像,但是docker本身可以将已有的镜像导出成tar文件,并且可以再次导入到docker,利用这一点,可以实现离线镜像文件的下载。
找一台可以联网的docker机器,并pull下载需要的镜像文件。
docker pull redis
docker pull node:18.19.0
然后使用如下命令将镜像文件导出:
docker save redis -o redis.tar
docker save node:18.19.0 -o node.tar
将tar文件上传到内网docker服务器,使用如下命令导入镜像文件:
docker load -i redis.tar
docker load -i node.tar
查看导入的镜像文件:
docker images
————————————————
版权声明:本文为CSDN博主「小志的博客」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/li1325169021/article/details/119920931