欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2020年09月10日 08:21:05   作者:胸大的請先講  
這篇文章主要介紹了在Idea中使用Docker部署SpringBoot項目的詳細教程,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

前言

項目需要:

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

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

下載地址:官網下載 Docker

安裝

一直下一步就行

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

在這里插入圖片描述

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

在這里插入圖片描述

測試是否安裝成功

C:\Users\msi>docker -v
Docker version 19.03.12, build 48a66213fe

C:\Users\msi> docker run hello-world

Hello 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 bash

Share 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 安裝

在這里插入圖片描述

2.配置Docker服務

file – 搜索docker – 選擇Docker – 右側添加一個Docker
Connection successful 顯示,表示 Docker鏈接成功

在這里插入圖片描述

三、創(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打包后復制進來的。

在這里插入圖片描述

Dockerfile 文件內容:

# From java image, version : 8
FROM java:8

# 掛載app目錄
VOLUME /app

# COPY or ADD to image
COPY demo-0.0.1-SNAPSHOT.jar app.jar

RUN bash -c "touch /app.jar"
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

maven打包,將其target目錄下的jar包復制進docker目錄下。

配置Dockerfile配置

在這里插入圖片描述

運行

在這里插入圖片描述

運行成功

在這里插入圖片描述

測試

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

在這里插入圖片描述

測試項目是否啟動:

在這里插入圖片描述

總結

今天學了下Docker容器,基本的命令學會了,但是一直沒弄懂怎么使用。借此機會就花費時間進行學習。目前只是會用,后面會補上步驟詳細描述。

到此這篇關于在Idea中使用Docker部署SpringBoot項目的文章就介紹到這了,更多相關Docker部署SpringBoot項目內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • docker中使用mysql數據庫詳解(在局域網訪問)

    docker中使用mysql數據庫詳解(在局域網訪問)

    這篇文章主要給大家介紹了在docker中使用mysql數據庫,在局域網訪問的相關資料,文中通過圖文以及示例代碼介紹的非常詳細,對大家具有一定的參考學習價值,需要的朋友們下面來一起看看吧。
    2017-06-06
  • docker 如何修改容器的端口

    docker 如何修改容器的端口

    正在運行的容器端口沖突了,但是還需要這個容器,怎么辦?只能修改端口了,今天通過本文給大家介紹docker 如何修改容器的端口,感興趣的朋友一起看看吧
    2024-01-01
  • docker安裝nginx并配置ssl的方法步驟

    docker安裝nginx并配置ssl的方法步驟

    本文主要介紹了docker安裝nginx并配置ssl的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2022-03-03
  • Docker教程之dockerfile構建centos鏡像

    Docker教程之dockerfile構建centos鏡像

    這篇文章主要介紹了Docker教程之dockerfile構建centos鏡像的相關資料,需要的朋友可以參考下
    2022-11-11
  • 基于Docker安裝與部署Zabbix

    基于Docker安裝與部署Zabbix

    zabbix是一個基于WEB界面的提供分布式系統(tǒng)監(jiān)視以及網絡監(jiān)視功能的企業(yè)級的開源解決方案。zabbix能監(jiān)視各種網絡參數,保證服務器系統(tǒng)的安全運營;并提供柔軟的通知機制以讓系統(tǒng)管理員快速定位/解決存在的各種問題。
    2018-04-04
  • docker在windows創(chuàng)建卷后本地找不到的完美解決方法

    docker在windows創(chuàng)建卷后本地找不到的完美解決方法

    這篇文章主要介紹了docker在windows創(chuàng)建卷后本地找不到的完美解決方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2024-02-02
  • Docker部署Tomcat的示例代碼

    Docker部署Tomcat的示例代碼

    本文主要介紹了Docker部署Tomcat的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-07-07
  • 使用Docker部署打包發(fā)布springboot項目

    使用Docker部署打包發(fā)布springboot項目

    本文主要介紹了使用Docker部署打包發(fā)布springboot項目,從安裝docker到多種方式打包發(fā)布,編譯,鏡像,容器等問題,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2022-03-03
  • 使用docker部署mysql并開啟binlog的方法

    使用docker部署mysql并開啟binlog的方法

    本文介紹了如何使用Docker部署MySQL服務并配置開啟binlog,以便通過Flink CDC Connector實現對MySQL數據的實時同步,有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2022-02-02
  • docker Dockerfile文件制作自己的鏡像的方法

    docker Dockerfile文件制作自己的鏡像的方法

    這篇文章主要介紹了docker Dockerfile文件制作自己的鏡像的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12

最新評論