您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇“SpringBoot打包docker镜像发布的方法”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“SpringBoot打包docker镜像发布的方法”文章吧。
只需要添加web依赖
[root@iZwz9hv1phm24s3jicy8x1Z idea]# ls Dockerfile Docker-Package-0.0.1-SNAPSHOT.jar [root@iZwz9hv1phm24s3jicy8x1Z idea]# docker build -t dongmu-springboot-project . Sending build context to Docker daemon 17.54MB Step 1/5 : FROM java:8 8: Pulling from library/java 5040bd298390: Pull complete fce5728aad85: Pull complete 76610ec20bf5: Pull complete 60170fec2151: Pull complete e98f73de8f0d: Pull complete 11f7af24ed9c: Pull complete 49e2d6393f32: Pull complete bb9cdec9c7f3: Pull complete Digest: sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d Status: Downloaded newer image for java:8 ---> d23bdf5b1b1b Step 2/5 : COPY /*.jar /app.jar ---> a16d648390df Step 3/5 : CMD ["--server.port=8080"] ---> Running in bc45f72484c7 Removing intermediate container bc45f72484c7 ---> 713861b331ad Step 4/5 : EXPOSE 8080 ---> Running in 7a28e4939b5e Removing intermediate container 7a28e4939b5e ---> 08f540832166 Step 5/5 : ENTRYPOINT ["java","-jar","/app.jar"] ---> Running in 6cd669cd522c Removing intermediate container 6cd669cd522c ---> 1fd9f50df534 Successfully built 1fd9f50df534 Successfully tagged dongmu-springboot-project:latest
[root@iZwz9hv1phm24s3jicy8x1Z idea]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE dongmu-springboot-project latest 1fd9f50df534 About a minute ago 661MB redis 5.0.9-alpine3.11 3661c84ee9d0 24 months ago 29.8MB tomcat 9.0.22 c856951ade0a 2 years ago 624MB java 8 d23bdf5b1b1b 5 years ago 643MB [root@iZwz9hv1phm24s3jicy8x1Z idea]# docker run -d -P --name dongmu-springboot-web dongmu-springboot-project c63282034de4e9dca727c93009e29f421bcd2544557a60b6339fa8056cc1d0d5
[root@iZwz9hv1phm24s3jicy8x1Z idea]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c63282034de4 dongmu-springboot-project "java -jar /app.jar …" 34 seconds ago Up 33 seconds 0.0.0.0:49166->8080/tcp, :::49166->8080/tcp dongmu-springboot-web [root@iZwz9hv1phm24s3jicy8x1Z idea]# curl localhost 49166 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Apache Tomcat/9.0.50</title> <link href="favicon.ico" rel="icon" type="image/x-icon" /> <link href="tomcat.css" rel="stylesheet" type="text/css" /> </head> ...... 访问成功
上面是内部访问,下面我们重新启动利用外网进行访问
[root@iZwz9hv1phm24s3jicy8x1Z idea]# docker run -d -p 3344:8080 --name dongmu-springboot-web dongmu-springboot-project 35f3b4fe0f9a4b878d6566a9f4334fc98e7841b1fc5eb7869dd0044d4fb44d6d
以上就是关于“SpringBoot打包docker镜像发布的方法”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。