亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

瀏覽:49日期:2023-09-25 15:49:45

前言

項目需要:

安裝Dockeridea中安裝docker插件,并配置docker一個SpringBoot項目創(chuàng)建Dockerfile

一、下載、安裝、配置Docker下載Docker

下載地址:官網(wǎng)下載 Docker

安裝

一直下一步就行

配置路徑:Settings?General 勾選 Expose daemon on tcp://localhost:2375 without TLS

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

設(shè)置鏡像,提高下載鏡像的速度https://xaiqlt1z.mirror.aliyuncs.com

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

測試是否安裝成功

C:Usersmsi>docker -vDocker version 19.03.12, build 48a66213feC:Usersmsi> docker run hello-worldHello from Docker!This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the 'hello-world' image from the Docker Hub. (amd64) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID: https://hub.docker.com/For more examples and ideas, visit: https://docs.docker.com/get-started/

二、Idea 安裝Docker插件

1.安裝docker插件在idea中: file--Plugins--Marketplace 搜索 Docker 安裝

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

2.配置Docker服務(wù)

file ? 搜索docker ? 選擇Docker ? 右側(cè)添加一個DockerConnection successful 顯示,表示 Docker鏈接成功

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

三、創(chuàng)建SpringBoot項目,修改pom.xmlspringMVC 項目,訪問 localhost:8080/hello 顯示 hello 字符串

@RequestMapping('/hello') @ResponseBody public String hello () { 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.創(chuàng)建Docker 文件

在main文件夾下創(chuàng)建一個docker文件夾,并在里面創(chuàng)建一個Dockerfile文件。xxxxx.jar 是使用maven打包后復(fù)制進(jìn)來的。

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

Dockerfile 文件內(nèi)容:

# From java image, version : 8FROM java:8# 掛載app目錄VOLUME /app# COPY or ADD to imageCOPY demo-0.0.1-SNAPSHOT.jar app.jarRUN bash -c 'touch /app.jar'EXPOSE 8080ENTRYPOINT ['java', '-jar', 'app.jar']

maven打包,將其target目錄下的jar包復(fù)制進(jìn)docker目錄下。

配置Dockerfile配置

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

運(yùn)行

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

運(yùn)行成功

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

測試

使用docker 檢查容器是否啟動:

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

測試項目是否啟動:

在Idea中使用Docker部署SpringBoot項目的詳細(xì)步驟

總結(jié)

今天學(xué)了下Docker容器,基本的命令學(xué)會了,但是一直沒弄懂怎么使用。借此機(jī)會就花費(fèi)時間進(jìn)行學(xué)習(xí)。目前只是會用,后面會補(bǔ)上步驟詳細(xì)描述。

到此這篇關(guān)于在Idea中使用Docker部署SpringBoot項目的文章就介紹到這了,更多相關(guān)Docker部署SpringBoot項目內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 另类欧美日韩 | 一级做a爱片特黄在线观看 一级做a爱片特黄在线观看免费看 | 亚洲国产精品久久久久网站 | 天天操综合网 | 中文字幕亚洲无线码高清 | 中文字幕成人在线 | 男女性高爱潮免费网站 | www.网站黄网站 | 国产视频在 | 大学生久久香蕉国产线观看 | 国产又黄不爽不遮挡视频 | 亚洲一区二区色 | 亚洲制服丝袜在线播放 | 欧美α一级毛片 | 国产亚洲欧洲国产综合一区 | 国产精品久久久久久福利 | 欧美xx毛片免费看 | 欧美精品一区二区三区在线 | 国产成人亚洲精品77 | 国产高清在线精品 | 日韩免费观看一级毛片看看 | 日日插天天操 | 男女啪视频大全1000 | 桐岛永久子 | 国产成人亚洲综合网站不卡 | 国产精品第三页 | 亚洲欧美中文v日韩v在线 | 日本中文字幕乱码aa高清电影 | 另类国产精品一区二区 | 国产片免费 | 欧美成人免费毛片 | 9191久久久久视频 | 高清女女同性一区二区 | 国产福利写真视频在线观看 | 中文国产成人精品少久久 | 久久久国产99久久国产首页 | 欧洲成人全免费视频网站 | 国产精品日本一区二区不卡视频 | 超乳w真性中出し冲田杏梨101 | 国产精品一区二 | 91视频最新网址 |