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

idea連接docker實現(xiàn)一鍵部署的方法

 更新時間:2020年10月22日 16:31:58   作者:伊布拉西莫  
這篇文章主要介紹了idea連接docker實現(xiàn)一鍵部署的方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

1.修改docker配置文件,打開2375端口

[root@s162 docker]# vim /usr/lib/systemd/system/docker.service
#查找 ExecStart,在末尾添加
#后面加上-H tcp://0.0.0.0:2375 

[root@s162 docker]# systemctl daemon-reload
[root@s162 docker]# systemctl start docker

## 查看2375端口是否啟用
[root@s162 docker]# lsof -i:2375
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
dockerd 27021 root 5u IPv6 352598799  0t0 TCP *:2375 (LISTEN)

2. Idea安裝配置docker插件

2.1. idea-plugins市場安裝docker插件

略…

2.2. 配置docker

在這里插入圖片描述

3.springboot項目部署到docker服務器

3.1. 編寫docker/dockerfile

在這里插入圖片描述

3.2.maven添加docker-maven-plugin插件

 <plugin>
   <groupId>com.spotify</groupId>
   <artifactId>docker-maven-plugin</artifactId>
   <version>1.0.0</version>
   <configuration>
    <!--指定生成的鏡像名,如果不指定tag,默認會使用latest-->
    <imageName>jhs/${project.artifactId}:${project.version}</imageName>
    <!--添加額外的指定標簽, 非必須-->
    <!--
    <imageTags>
     <imageTag>${project.version}</imageTag>
    </imageTags>
    -->

    <!-- 指定 Dockerfile 路徑 :項目根路徑下-->
    <dockerDirectory>${project.basedir}/docker</dockerDirectory>
    <!--指定遠程 docker api地址-->
    <dockerHost>http://192.168.129.162:2375</dockerHost>


    <!-- copy資源 -->
    <resources>
     <resource>
      <targetPath>/</targetPath>
      <directory>${project.build.directory}</directory>
      <include>${project.build.finalName}.jar</include>
     </resource>
    </resources>


    <!--docker build dockerfile時:設置鏡像創(chuàng)建時的變量 -->
    <buildArgs>
     <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
    </buildArgs>
   </configuration>
  </plugin>

3.3. docker:build

使用命令$ mvn clean package docker:build -Dmaven.test.skip=true構建鏡像,在docker服務器上查看鏡像是否上傳成功:

在這里插入圖片描述

3.4 docker:tag

docker命令行格式為#docker tag <imageId or imageName> <nexus-hostname>:<repository-port>/<image>:<tag>

插件配置
<configuration>補充配置:

 <configuration>
	 <image>jhs/${project.artifactId}:${project.version}</image>
  <!-- docker tag 打標簽-->
  <newName>192.168.129.160:5000/${project.artifactId}:${project.version}</newName>
</configuration>

為鏡像打上tag標簽,為后續(xù)的push做準備:mvn clean docker:tag -Dmaven.test.skip=true -DskipDockerBuild

在這里插入圖片描述

3.5 docker:push

插件配置
<configuration>補充配置:

<configuration>
	 <!-- docker push 推送到遠程鏡像倉庫-->
  <!-- serverId: 為在maven setting.xml配置的server信息id-->
  <serverId>nexus-docker-registry</serverId>
  <registryUrl>192.168.129.160:5000</registryUrl>
  	
  	<!-- 打上tag的新鏡像 push 到nexus-->
		<imageName>192.168.129.160:5000/${project.artifactId}</imageName>
</configuration>

將上文打上tag標簽的鏡像,推送到私服nexus:mvn clean docker:push -Dmaven.test.skip=true -DskipDockerBuild -DskipDockerTag

在這里插入圖片描述

3.6 docker插件參數(shù)

  • -DskipDockerBuild to skip image build
  • -DskipDockerTag to skip image tag
  • -DskipDockerPush to skip image push
  • -DskipDockerto skip any Docker goals

3.7 綁定命令到maven phases

<executions>
  <execution>
   <id>build-image</id>
   <phase>package</phase>
   <goals>
    <goal>build</goal>
   </goals>
  </execution>

  <execution>
   <id>tag-image</id>
   <phase>package</phase>
   <goals>
    <goal>tag</goal>
   </goals>
   <configuration>
    <image>jhs/${project.artifactId}:${project.version}</image>
    <newName>192.168.129.160:5000/${project.artifactId}:${project.version}</newName>
   </configuration>
  </execution>


  <execution>
   <id>push-image</id>
   <phase>deploy</phase>
   <goals>
    <goal>push</goal>
   </goals>
   <configuration>
    <!-- docker push 推送到遠程鏡像倉庫-->
    <!-- serverId: 為在maven setting.xml配置的server信息id-->
    <serverId>nexus-docker-registry</serverId>
    <registryUrl>192.168.129.160:5000</registryUrl>
    <imageName>192.168.129.160:5000/${project.artifactId}</imageName>
   </configuration>
  </execution>

 </executions>

3.8 最佳實踐

 <properties>
  <docker.host>http://192.168.129.162:2375</docker.host>
  <docker.registry.url>192.168.129.160:5000</docker.registry.url>
 </properties>
 
<build>
 <plugins>
 	<plugin>
  <groupId>com.spotify</groupId>
  <artifactId>docker-maven-plugin</artifactId>
  <version>1.0.0</version>
  <configuration>
   <imageName>dic/${project.artifactId}:${project.version}</imageName>
   <!--添加額外的指定標簽(可配置多個), 若果沒做指定,則為latest-->
   <!--
    <imageTags>
     <imageTag>${project.version}</imageTag>
    </imageTags>
    -->


   <!-- 指定 Dockerfile 路徑 :項目根路徑下-->
   <dockerDirectory>${project.basedir}/docker</dockerDirectory>
   <!--指定遠程 docker api地址-->
   <dockerHost>${docker.host}</dockerHost>


   <!-- copy資源 -->
   <resources>
    <resource>
     <targetPath>/</targetPath>
     <directory>${project.build.directory}</directory>
     <include>${project.build.finalName}.jar</include>
    </resource>
   </resources>


   <!--docker build dockerfile時:設置鏡像創(chuàng)建時的變量 -->
   <buildArgs>
    <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
   </buildArgs>
  </configuration>

  <executions>
   <execution>
    <id>build-image</id>
    <phase>package</phase>
    <goals>
     <goal>build</goal>
    </goals>
   </execution>

   <execution>
    <id>tag-image</id>
    <phase>package</phase>
    <goals>
     <goal>tag</goal>
    </goals>
    <configuration>
     <image>dic/${project.artifactId}:${project.version}</image>
     <newName>${docker.registry.url}/${project.artifactId}:${project.version}</newName>
    </configuration>
   </execution>


   <execution>
    <id>push-image</id>
    <phase>deploy</phase>
    <goals>
     <goal>push</goal>
    </goals>
    <configuration>
     <!-- docker push 推送到遠程鏡像倉庫-->
     <!-- serverId: 為在maven setting.xml配置的server信息id-->
     <serverId>nexus-docker-registry</serverId>
     <registryUrl>${docker.registry.url}</registryUrl>
     <imageName>${docker.registry.url}/${project.artifactId}</imageName>
    </configuration>
   </execution>

  </executions>
 </plugin>
 </plugins>
 </build>

4.Docker私服倉庫Harbor安裝的步驟詳解(補充)

http://www.dbjr.com.cn/article/161964.htm

到此這篇關于idea連接docker實現(xiàn)一鍵部署的文章就介紹到這了,更多相關idea連接docker一鍵部署內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • 詳解Docker Volume 之權限管理

    詳解Docker Volume 之權限管理

    這篇文章主要介紹了詳解Docker Volume 之權限管理,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-10-10
  • Docker中運行nginx并掛載本地目錄到鏡像中的方法

    Docker中運行nginx并掛載本地目錄到鏡像中的方法

    這篇文章主要介紹了Docker中運行nginx并掛載本地目錄到鏡像中的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-01-01
  • CentOS7.6系統(tǒng)下Docker安裝部署教程

    CentOS7.6系統(tǒng)下Docker安裝部署教程

    這篇文章主要為大家介紹了CentOS7.6系統(tǒng)下Docker的安裝部署教程,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步早日升職加薪
    2022-04-04
  • 云原生之使用Docker部署homer靜態(tài)主頁的方法步驟

    云原生之使用Docker部署homer靜態(tài)主頁的方法步驟

    本文主要介紹了云原生之使用Docker部署homer靜態(tài)主頁的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-08-08
  • 詳解Docker私有倉庫Registry的搭建驗證

    詳解Docker私有倉庫Registry的搭建驗證

    這篇文章主要介紹了詳解Docker私有倉庫Registry的搭建驗證,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • Docker安裝Redis容器的實現(xiàn)步驟

    Docker安裝Redis容器的實現(xiàn)步驟

    本文主要介紹了Docker安裝Redis容器的實現(xiàn)步驟,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • docker search命令的具體使用

    docker search命令的具體使用

    本文主要介紹了docker search命令的具體使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2023-02-02
  • docker數(shù)據(jù)卷容器掛載不上的解決方法

    docker數(shù)據(jù)卷容器掛載不上的解決方法

    docker容器之間可以通過相互掛載實現(xiàn)數(shù)據(jù)共享,本文主要介紹了docker數(shù)據(jù)卷容器掛載不上的解決方法,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學習學習吧
    2023-06-06
  • Docker深度清除鏡像緩存overlay2的實現(xiàn)

    Docker深度清除鏡像緩存overlay2的實現(xiàn)

    維清理鏡像是通過命令?docker?rm?i?刪除鏡像的,但是這條命令不會刪除docker?build命令產(chǎn)生的緩存文件,本文主要介紹了Docker深度清除鏡像緩存overlay2的實現(xiàn),感興趣的可以了解一下
    2023-12-12
  • Docker?Desktop?安裝的詳細步驟

    Docker?Desktop?安裝的詳細步驟

    作為開發(fā)人員,在日常開發(fā)中,我們需要在本地去啟動一些服務,可以使用Docker?Desktop,本文主要介紹了Docker?Desktop?安裝的詳細步驟,感興趣的可以了解一下
    2023-08-08

最新評論