FROM java:8 #COPY *.jar /app.jar
# || ADD springbootdemo-0.0.1-SNAPSHOT.jar /app.jar # add 自带解压功能 EXPOSE 8080 CMD ["-----serverport:8080--------"] ENTRYPOINT ["java","-jar","/app.jar"]
3.
[root@lvym springboot]# docker build -t myboot2 . Sending build context to Docker daemon 2.048kB Step 1/5 : FROM java:8 ---> d23bdf5b1b1b Step 2/5 : COPY *.jar /app.jar COPY failed: no source files were specified 没有生成镜像就删除jar,报的错 [root@lvym springboot]# docker build -t myboot2 . Sending build context to Docker daemon 2.048kB Step 1/5 : FROM java:8 ---> d23bdf5b1b1b
..........
[root@lvym springboot]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myboot2 latest 5f5431d90366 11 seconds ago 660MB
[root@lvym springboot]# docker run -d -P myboot2
170c932ab4558fb6774d820e851e25787bc9052d98e458d979f8c75d0103f515
[root@lvym springboot]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
170c932ab455 myboot2 "java -jar /app.jar …" 8 seconds ago Up 7 seconds 0.0.0.0:32776->8080/tcp heuristic_lehmann
[root@lvym springboot]# curl localhost:32776/test
test环境[root@lvym springboot]#