docker部署springboot

概述

使用docker部署springboot项目

部署

编写Dockerfile

wangzheng@wangzheng-ubuntu:~/app$ ls
demo-0.0.1-SNAPSHOT.jar  Dockerfile

wangzheng@wangzheng-ubuntu:~/app$ cat Dockerfile 
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD demo-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

docker build 镜像

wangzheng@wangzheng-ubuntu:~/app$ docker build -f ./Dockerfile -t wz/app . 
Sending build context to Docker daemon  31.38MB
Step 1/4 : FROM openjdk:8-jdk-alpine
 ---> 792ff45a2a17
Step 2/4 : VOLUME /tmp
 ---> Running in 37ac55483c67
Removing intermediate container 37ac55483c67
 ---> 0225f21dac36
Step 3/4 : ADD demo-0.0.1-SNAPSHOT.jar app.jar
 ---> bdf8968ed2e5
Step 4/4 : ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
 ---> Running in 592ef9340eff
Removing intermediate container 592ef9340eff
 ---> bc544f9e9913
Successfully built bc544f9e9913
Successfully tagged wz/app:latest

docker run创建新容器并运行

wangzheng@wangzheng-ubuntu:~/app$ docker run -it -p 80:80 wz/app

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.3.RELEASE)

2019-02-21 08:41:10.797  INFO 1 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication v0.0.1-SNAPSHOT on a10c7b038ee7 with PID 1 (/app.jar started by root in /)
2019-02-21 08:41:10.816  INFO 1 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to default profiles: default
2019-02-21 08:41:15.465  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$110175f] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-02-21 08:41:15.766  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.hateoas.config.HateoasConfiguration' of type [org.springframework.hateoas.config.HateoasConfiguration$$EnhancerBySpringCGLIB$$80906491] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-02-21 08:41:17.080  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 80 (http)
2019-02-21 08:41:17.226  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

wangzheng@wangzheng-ubuntu:~$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
0641038046b5        wz/app              "java -Djava.securit…"   3 seconds ago       Up 2 seconds        0.0.0.0:80->80/tcp        gallant_clarke
399ac7866dbb        mysql:5.6           "docker-entrypoint.s…"   5 weeks ago         Up About an hour    0.0.0.0:12345->3306/tcp   mysql

外部浏览器访问

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值