在Idea中使用Docker部署SpringBoot项目的详细步骤

在Idea中使用Docker部署SpringBoot项目的详细步骤,第1张

Idea中使用Docker部署SpringBoot项目的详细步骤

本文详细介绍了在Idea中用Docker部署新SpringBoot项目的详细示例教程,非常详细的给大家。对大家的学习、培训或者工作都有一定的参考价值,一定要朋友们参考。

序言

新项目必须:

在dockeridea中安装docker软件,将Docker配置为新的SpringBoot项目,建立Dockerfile。

一、下载、安装、配置Docker下载Docker

下载地址:官网下载Docker

固定

继续下一步就好。

Settings-General在没有TLS的情况下在TCP://localhost:2375上启用expose守护程序。

设置镜像系统,提高镜像系统的下载速度。https://xaiqlt1z.mirror.aliyuncs.com。

检查安装是否成功。

C:\Users\msi>docker-v Dockerversion19.03.12,build48a66213fe C:\Users\msi>dockerrunhello-world HellofromDocker! Thismessageshowsthatyourinstallationappearstobeworkingcorrectly. Togeneratethismessage,Dockertookthefollowingsteps: 1.TheDockerclientcontactedtheDockerdaemon. 2.TheDockerdaemonpulledthe"hello-world"imagefromtheDockerHub. (amd64) 3.TheDockerdaemoncreatedanewcontainerfromthatimagewhichrunsthe executablethatproducestheoutputyouarecurrentlyreading. 4.TheDockerdaemonstreamedthatoutputtotheDockerclient,whichsentit toyourterminal. Totrysomethingmoreambitious,youcanrunanUbuntucontainerwith: $dockerrun-itubuntubash Shareimages,automateworkflows,andmorewithafreeDockerID: https://hub.docker.com/ Formoreexamplesandideas,visit: https://docs.docker.com/get-started/

二。Idea安装Docker软件

1.在idea中安装docker软件:文件文件插件市场检索Docker安装。

2.配置Docker服务项目

文件-检索Docker-选择Docker-添加Docker
连接成功右侧显示信息,表示Docker连接成功。

3.建立一个新的SpringBoot项目,更改新的pom.xmlspringMVC项目,浏览localhost:8080/hello显示hello字符串数组的信息。

@RequestMapping("/hello") @ResponseBody publicStringhello(){ return"hello"; }

1.配置pom.xml文档

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>com.spotify</groupId> <artifactId>docker-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <id>build-image</id> <phase>package</phase> <goals> <goal>build</goal> </goals> </execution> </executions> <configuration> <imageName>${project.artifactId}</imageName> <imageTags> <imageTag>latest</imageTag> </imageTags> <dockerDirectory>${project.basedir}</dockerDirectory> <dockerHost>http://localhost:2375</dockerHost> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}</include> </resource> </resources> </configuration> </plugin> </plugins> </build>

2.建立Docker文档

在主文件夹名称下设置一个docker文件夹名称,并在其中设置一个Dockerfile文档。Xxxxx.jar是maven打包复制进来的。

Dockerfile文档内容:

#Fromjavaimage,version:8 FROMjava:8 #初始化app文件目录 VOLUME/app #COPYorADDtoimage COPYdemo-0.0.1-SNAPSHOT.jarapp.jar RUNbash-c"touch/app.jar" EXPOSE8080 ENTRYPOINT["java","-jar","app.jar"]

Maven安装这个包,并将目标文件目录中的jar包复制到docker文件目录中。

配置Dockerfile配置

*** 作

手术成功

考试

检查船只是否由码头工人启动;

测试报告是否开始:

摘要

今天学了Docker的用具,基本的使用说明也学会了,但是一直不知道怎么用。你可以借此机会把时间花在学习和培训上。现阶段只会用到,后面会完成流程的详细描述。

到目前为止,这篇关于用Docker在Idea中部署新的SpringBoot项目的文章已经在这里详细介绍过了。关于使用Docker部署新SpringBoot项目的大量信息,请搜索您以前的文章或再次访问下面的相关文章。期待你以后更多的应用!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/774366.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-03
下一篇 2022-05-03

发表评论

登录后才能评论

评论列表(0条)

保存