婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > idea連接docker實現一鍵部署的方法

idea連接docker實現一鍵部署的方法

熱門標簽:ai電話機器人營銷 山東電信外呼系統靠譜嗎 鸚鵡螺號航海地圖標注時間 云南云電銷機器人招商 信貸電銷機器人系統 江蘇自動外呼系統一般多少錢 長沙回撥外呼系統 比較穩定的外呼系統 400 電話 申請費用

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時:設置鏡像創建時的變量 -->
    <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標簽,為后續的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插件參數

  • -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時:設置鏡像創建時的變量 -->
   <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安裝的步驟詳解(補充)

https://www.jb51.net/article/161964.htm

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

標簽:衡陽 拉薩 烏海 齊齊哈爾 澳門 運城 嘉興 亳州

巨人網絡通訊聲明:本文標題《idea連接docker實現一鍵部署的方法》,本文關鍵詞  idea,連接,docker,實現,一鍵,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《idea連接docker實現一鍵部署的方法》相關的同類信息!
  • 本頁收集關于idea連接docker實現一鍵部署的方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 彭州市| 江西省| 拜城县| 图木舒克市| 清流县| 郯城县| 岳普湖县| 容城县| 安庆市| 平阴县| 安徽省| 深圳市| 澄城县| 肇东市| 华容县| 屏山县| 株洲县| 六盘水市| 贵溪市| 和平县| 托克托县| 青冈县| 定远县| 海丰县| 钟祥市| 凉城县| 宝坻区| 鹤壁市| 十堰市| 海口市| 巩留县| 自贡市| 抚远县| 鹤岗市| 郓城县| 广汉市| 萍乡市| 华安县| 昂仁县| 台江县| 丰原市|