Docker离线环境部署以及镜像导入
1.下载docker源码包
https://download.docker.com/linux/static/stable/x86_64/
2.解压
tar -zxf docker-19.03.8.tgz
3.将解压文件复制到/usr/bin
cp docker/* /usr/bin
4.设置启动服务
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
# 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=/opt/software/docker/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.targe
5.增加权限
chmod +x /etc/systemd/system/docker.service
6.启动项生效
systemctl daemon-reload
7.启动服务
systemctl start docker.service
8.从其他可以连接网络的服务器上导出镜像
docker save -o java.tar java
9.通过工具上传到离线服务器,然后导入
docker load -i java.tar
运行一个jar包程序实例。
docker run -d --name doctor -v /opt/logs:/logs -v /opt/syh.jar:/opt/syh.jar java java -jar /opt/syh.jar --spring.profiles.active=dev