maven構(gòu)建docker鏡像push到鏡像倉庫方式
更新時間:2023年11月28日 09:09:19 作者:乄名007
這篇文章主要介紹了maven構(gòu)建docker鏡像push到鏡像倉庫方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
maven構(gòu)建docker鏡像push到鏡像倉庫
registry私人鏡像倉庫
docker pull hub.c.163.com/library/registry:latest Docker tag imageid registry docker run -d -p 5000:5000 -v /Users/zhongxing/docker/registry/opt:/var/lib/registry registry
pom.xml:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>base-eureka</artifactId> <packaging>jar</packaging> <name>base-eureka</name> <description>Demo project for Spring Boot</description> <parent> <groupId>com.zxing</groupId> <artifactId>base-ms</artifactId> <version>1.0-SNAPSHOT</version> </parent> <properties> <docker.registry>192.168.20.200:5000</docker.registry> <push.image>true</push.image> </properties> <dependencies> <dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.10</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> </dependencies> <build> <resources> <resource> <directory>src/main/resources</directory> </resource> <resource> <directory>${env}</directory> <filtering>true</filtering> </resource> </resources> <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>0.4.13</version> <configuration> <imageName>${docker.registry}/${project.groupId}/${project.artifactId}:${project.version}</imageName> <dockerDirectory>${basedir}/src/main/docker</dockerDirectory> <pushImage>${push.image}</pushImage> <resources> <resource> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration> </plugin> </plugins> </build> </project>
Dockerfile:
FROM java:8 ADD base-eureka-1.0-SNAPSHOT.jar app.jar CMD ["java","-jar","app.jar"]
mac配置insecure registrie
(docker push fail。。。)
maven運(yùn)行:
docker:build
打包結(jié)果:
運(yùn)行:
docker run -d -p 8761:8761 --name=eureka 192.168.20.200:5000/com.zxing/base-eureka:1.0-SNAPSHOT
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
詳解Centos7 下建立 Docker 橋接網(wǎng)絡(luò)
本篇文章主要介紹了詳解Centos7 下建立 Docker 橋接網(wǎng)絡(luò),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-01-01docker 安裝、升級、修改數(shù)據(jù)目錄的操作方法
這篇文章主要介紹了docker 安裝、升級、修改數(shù)據(jù)目錄的操作方法,本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧2024-08-08docker容器狀態(tài)的轉(zhuǎn)換實現(xiàn)
這篇文章主要介紹了docker容器狀態(tài)的轉(zhuǎn)換實現(xiàn),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11