Springboot微服务打包Docker镜像流程解析
1.构建springboot项目
2.打包应用
3.编写dockerfile
4.构建镜像
5.发布运行!
[root@localhostdemo]#ls demo02-0.0.1-SNAPSHOT.jarDockerfile #Dockerfile文件 [root@localhostdemo]#catDockerfile FROMjava:8 COPY*.jar/app.jar CMD["--server.port=8080"] EXPOSE8080 ENTRYPOINT["java","-jar","/app.jar"] #构建镜像 [root@localhostdemo]#dockerbuild-tmyapp. SendingbuildcontexttoDockerdaemon16.52MB Step1/5:FROMjava:8 8:Pullingfromlibrary/java 5040bd298390:Pullcomplete fce5728aad85:Pullcomplete 76610ec20bf5:Pullcomplete 60170fec2151:Pullcomplete e98f73de8f0d:Pullcomplete 11f7af24ed9c:Pullcomplete 49e2d6393f32:Pullcomplete bb9cdec9c7f3:Pullcomplete Digest:sha256:c1ff613e8ba25833d2e1940da0940c3824f03f802c449f3d1815a66b7f8c0e9d Status:Downloadednewerimageforjava:8 --->d23bdf5b1b1b Step2/5:COPY*.jar/app.jar --->5da95c636893 Step3/5:CMD["--server.port=8080"] --->Runninginfa572a071b60 Removingintermediatecontainerfa572a071b60 --->923a3dc22971 Step4/5:EXPOSE8080 --->Runninginab336abf9423 Removingintermediatecontainerab336abf9423 --->41946a7a1a04 Step5/5:ENTRYPOINT["java","-jar","/app.jar"] --->Runningindcd4cb40838c Removingintermediatecontainerdcd4cb40838c --->edcc53f97c94 Successfullybuiltedcc53f97c94 Successfullytaggedmyapp:latest [root@localhostdemo]#dockerimages REPOSITORYTAGIMAGEIDCREATEDSIZE myapplatestedcc53f97c94Aboutaminuteago660MB java8d23bdf5b1b1b3yearsago643MB ##运行镜像 [root@localhostdemo]#dockerrun-d-p8080:8080myapp 4aa0eefb1c5d53d752ade949625683a61acc2e5bfe642614b1ae68533b279dae #访问测试 [root@localhostdemo]#curllocalhost:8080/hello/hello hello[root@localhostdemo]# #访问成功
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。