在生成的目录下,建立个文件,文件名称为:Dockerfile
FROM java:8
VOLUME /tmp
ADD target/assignment-0.0.1-SNAPSHOT.jar /dalaoyang.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/dalaoyang.jar"]
在Post step下,写以下命令
set imagesV=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
docker image build -t njiandan/spring-boot-2-rest-service-basic:%imagesV% .
docker push njiandan/spring-boot-2-rest-service-basic:%imagesV%
这样就可以发布内容到hub.docker
最后在执行以下命令进行启动
#!/bin/sh
# 停掉旧的容器
docker stop `docker ps -aq --filter ancestor=njiandan/spring-boot-2-rest-service-basic:$time2`# 删除旧的容器
docker rm `docker ps -aq --filter ancestor=njiandan/spring-boot-2-rest-service-basic:$time2`# 删除旧的镜像(包含项目的)
docker rmi njiandan/spring-boot-2-rest-service-basic:$time2#取时间戳来当版本信息
time2=$(date "+%Y%m%d%H%M%S")
echo $time2
#创建镜像
cd /
chmod 777 /home/war-jar-bak/Dockerfile
cd /home/war-jar-bak
echo image build -f /home/war-jar-bak/Dockerfile -t njiandan/spring-boot-2-rest-service-basic:$time2 .
docker image build -f /home/war-jar-bak/Dockerfile -t njiandan/spring-boot-2-rest-service-basic:$time2 .#上传镜像
#docker push njiandan/spring-boot-2-rest-service-basic:$time2#启动镜像
docker run -p 8080:8086 -t njiandan/spring-boot-2-rest-service-basic:$time2
{"registry-mirrors": ["https://s5sff5og.mirror.aliyuncs.com"],"insecure-registries":["124.70.164.58:5000","81.69.234.227:5000"]
}
以上是 Portainer.io 镜像库的设置映射 https http