最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

1.修改docker配置文件,打開(kāi)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市場(chǎng)安裝docker插件

略…

2.2. 配置docker

在這里插入圖片描述

3.springboot項(xiàng)目部署到docker服務(wù)器

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,默認(rèn)會(huì)使用latest-->
    <imageName>jhs/${project.artifactId}:${project.version}</imageName>
    <!--添加額外的指定標(biāo)簽, 非必須-->
    <!--
    <imageTags>
     <imageTag>${project.version}</imageTag>
    </imageTags>
    -->

    <!-- 指定 Dockerfile 路徑 :項(xiàng)目根路徑下-->
    <dockerDirectory>${project.basedir}/docker</dockerDirectory>
    <!--指定遠(yuǎn)程 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時(shí):設(shè)置鏡像創(chuàng)建時(shí)的變量 -->
    <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構(gòu)建鏡像,在docker服務(wù)器上查看鏡像是否上傳成功:

在這里插入圖片描述

3.4 docker:tag

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

插件配置
<configuration>補(bǔ)充配置:

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

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

在這里插入圖片描述

3.5 docker:push

插件配置
<configuration>補(bǔ)充配置:

<configuration>
	 <!-- docker push 推送到遠(yuǎn)程鏡像倉(cāng)庫(kù)-->
  <!-- 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標(biāo)簽的鏡像,推送到私服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 推送到遠(yuǎn)程鏡像倉(cāng)庫(kù)-->
    <!-- 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 最佳實(shí)踐

 <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>
   <!--添加額外的指定標(biāo)簽(可配置多個(gè)), 若果沒(méi)做指定,則為latest-->
   <!--
    <imageTags>
     <imageTag>${project.version}</imageTag>
    </imageTags>
    -->


   <!-- 指定 Dockerfile 路徑 :項(xiàng)目根路徑下-->
   <dockerDirectory>${project.basedir}/docker</dockerDirectory>
   <!--指定遠(yuǎn)程 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時(shí):設(shè)置鏡像創(chuàng)建時(shí)的變量 -->
   <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 推送到遠(yuǎn)程鏡像倉(cāng)庫(kù)-->
     <!-- 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私服倉(cāng)庫(kù)Harbor安裝的步驟詳解(補(bǔ)充)

http://m.fzitv.net/article/161964.htm

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

相關(guān)文章

最新評(píng)論

平湖市| 余姚市| 西丰县| 邯郸县| 安龙县| 湖北省| 房产| 武乡县| 新巴尔虎左旗| 仁布县| 错那县| 宜君县| 新安县| 洛宁县| 靖西县| 宝鸡市| 镇平县| 星子县| 兰州市| 神木县| 西乌珠穆沁旗| 高雄县| 高密市| 安阳市| 霸州市| 保靖县| 平塘县| 北票市| 青铜峡市| 广德县| 章丘市| 岳普湖县| 富川| 岱山县| 沙洋县| 南投市| 河津市| 万宁市| 来安县| 黄陵县| 绥滨县|