首页  

springboot应用打docker镜像     所属分类 docker 浏览量 585
先编译生成jar包
mvn clean   install -Dmaven.test.skip
再打镜像
docker build -t dyyx/hello:v1 .

springboot-docker-demo/Dockerfile

FROM java:8
# FROM openjdk:8u312-slim
ARG JAR_FILE=target/springboot-docker-demo-1.0.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]


ENTRYPOINT 两种写法 exec写法 JSON风格 ENTRYPOINT ["java","${JAVA_OPTS}","-jar","/app.jar"] shell写法 ENTRYPOINT java ${JAVA_OPTS} -jar /app.jar
docker images REPOSITORY TAG IMAGE ID CREATED SIZE dyyx/hello v1 c478a67bbc60 3 minutes ago 660MB docker run --name myhello -d -p 8088:8088 dyyx/hello:v1 docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES edad41b18158 dyyx/hello:v1 "java -jar /app.jar" 5 minutes ago Up 5 minutes 0.0.0.0:8088->8088/tcp myhello docker exec -it edad41b18158 /bin/sh docker exec -it myhello /bin/sh http://127.0.0.1:8088/ http://127.0.0.1:8088/hello http://127.0.0.1:8088/log?level=info&msg=info
-rw-r--r-- 1 root root 17049477 Aug 23 08:38 app.jar -rw-r--r-- 1 root root 99671 Aug 24 00:44 app.log drwxr-xr-x 2 root root 4096 May 9 2019 bin drwxr-xr-x 5 root root 340 Aug 24 00:43 dev drwxr-xr-x 1 root root 4096 Aug 24 00:43 etc drwxr-xr-x 2 root root 4096 May 9 2019 home drwxr-xr-x 1 root root 4096 May 17 2019 lib drwxr-xr-x 5 root root 4096 May 9 2019 media drwxr-xr-x 2 root root 4096 May 9 2019 mnt drwxr-xr-x 2 root root 4096 May 9 2019 opt dr-xr-xr-x 211 root root 0 Aug 24 00:43 proc drwx------ 1 root root 4096 Aug 24 00:44 root drwxr-xr-x 2 root root 4096 May 9 2019 run drwxr-xr-x 2 root root 4096 May 9 2019 sbin drwxr-xr-x 2 root root 4096 May 9 2019 srv dr-xr-xr-x 13 root root 0 Aug 24 00:43 sys drwxrwxrwt 1 root root 4096 Aug 24 00:43 tmp drwxr-xr-x 1 root root 4096 May 17 2019 usr drwxr-xr-x 1 root root 4096 May 9 2019 var
例子项目 https://gitee.com/dyyx/hellocode/tree/master/demo/springboot-docker-demo
docker常用命令 docker命令实战

上一篇     下一篇
centos7 离线安装 docker

实用的财经网站

计算机网络笔记

java8 docker 镜像大小

springboot 应用 docker 挂载外部配置文件

dockerfile 写法