Use docker-maven-plugin construct plugins docker mirror (obsolete)

Can refer to blog: https://blog.csdn.net/aixiaoyang168/article/details/77453974

docker-maven-plugin's official website recommended to build the mirror using dockerfile-maven in new projects.

docker-maven-plugin of Github Address: https://github.com/spotify/docker-maven-plugin

dockerfile-maven of Github Address: https://github.com/spotify/dockerfile-maven

 

First, the use docker-maven-plugin mirroring Construction

docker-maven-plugin used in two ways, one is to use Dockerfile file, one is not using Dockerfile file.

1. Construction of the information specified in the POM (without Dockerfile file)

The introduction of the plug-in pom.xml

Copy the code
<-! Docker-maven-plugin plugin (without Dockerfile File) -> 
<plugin> 
    <the groupId> com.spotify </ the groupId> 
    <the artifactId> Docker-Maven-plugin </ the artifactId> 
    <Version> 0.4.13 </ Version> 
    <Configuration> 
        <- - specifies the image name!> 
        <imageName> the project.name} {$: $ {project.version} </ imageName> 
        <- specifies the base image, rather! Dockerfile in the FROM instruction -> 
        <baseImage> Java </ baseImage> 
        <-! ENTRYPOINT corresponding to the instruction Dockerfile -> 
        <the entryPoint> [ "Java", "-jar", "/${project.build } .jar .finalName "] </ the entryPoint> 
        <-! Build whether to skip Docker -> 
        <skipDockerBuild>true</skipDockerBuild>
        <resources>
            <resource>
                <The targetPath> / </ The targetPath> 
                <-! specifies the need to copy the root directory, $ {project.build.directory} represents a target directory -> 
                <Directory> project.build.directory $ {} </ Directory> 
                <! - used to specify the file to be copied. $ {project.build.finalName} .jar file refers to the packaged jar package. -> 
                <the include> $} {project.build.finalName .jar </ the include> 
            </ Resource> 
        </ Resources> 
    </ Configuration> 
</ plugin>
Copy the code

By default, the plug-in by visiting localhost: 2375 to connect local docker, can be connected docker DOCKER_HOST by setting environment variables.

DOCKER_HOST=tcp://<host>:2375

2. Use Dockerfile file

If you use Dockerfile file, you must specify dockerDirectory element, then baseImage, maintainer, cmd and entryPoint these elements will be ignored. dockerDirectory elements in the specified content is to be copied to the $ {project.build.directory} / docker, other files will be replicated resources element other than, for example, project jar file.

Copy the code
<!--docker-maven-plugin插件(带Dockerfile文件)-->
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.13</version>
    <configuration>
        <imageName>${project.name}:${project.version}</imageName>
        <!--Dockerfile文件位置-->
        <dockerDirectory>docker</dockerDirectory>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.jar</include>
            </resource>
        </resources>
    </configuration>
</plugin>
Copy the code

 

Second, the use

Create a mirror

mvn clean package docker:build

Push the mirror to Registry

mvn clean package docker:build -DpushImage

Tag to specify the mirror push Registry

mvn clean package docker:build -DpushImageTag

Third, Docker command to bind the various stages Maven

 

Original Address: https://www.cnblogs.com/rouqinglangzi/p/10021838.html

Can refer to blog: https://blog.csdn.net/aixiaoyang168/article/details/77453974

docker-maven-plugin's official website recommended to build the mirror using dockerfile-maven in new projects.

docker-maven-plugin of Github Address: https://github.com/spotify/docker-maven-plugin

dockerfile-maven of Github Address: https://github.com/spotify/dockerfile-maven

 

First, the use docker-maven-plugin mirroring Construction

docker-maven-plugin used in two ways, one is to use Dockerfile file, one is not using Dockerfile file.

1. Construction of the information specified in the POM (without Dockerfile file)

The introduction of the plug-in pom.xml

Copy the code
<-! Docker-maven-plugin plugin (without Dockerfile File) -> 
<plugin> 
    <the groupId> com.spotify </ the groupId> 
    <the artifactId> Docker-Maven-plugin </ the artifactId> 
    <Version> 0.4.13 </ Version> 
    <Configuration> 
        <- - specifies the image name!> 
        <imageName> the project.name} {$: $ {project.version} </ imageName> 
        <- specifies the base image, rather! Dockerfile in the FROM instruction -> 
        <baseImage> Java </ baseImage> 
        <-! ENTRYPOINT corresponding to the instruction Dockerfile -> 
        <the entryPoint> [ "Java", "-jar", "/${project.build } .jar .finalName "] </ the entryPoint> 
        <-! Build whether to skip Docker -> 
        <skipDockerBuild>true</skipDockerBuild>
        <resources>
            <resource>
                <The targetPath> / </ The targetPath> 
                <-! specifies the need to copy the root directory, $ {project.build.directory} represents a target directory -> 
                <Directory> project.build.directory $ {} </ Directory> 
                <! - used to specify the file to be copied. $ {project.build.finalName} .jar file refers to the packaged jar package. -> 
                <the include> $} {project.build.finalName .jar </ the include> 
            </ Resource> 
        </ Resources> 
    </ Configuration> 
</ plugin>
Copy the code

By default, the plug-in by visiting localhost: 2375 to connect local docker, can be connected docker DOCKER_HOST by setting environment variables.

DOCKER_HOST=tcp://<host>:2375

2. Use Dockerfile file

If you use Dockerfile file, you must specify dockerDirectory element, then baseImage, maintainer, cmd and entryPoint these elements will be ignored. dockerDirectory elements in the specified content is to be copied to the $ {project.build.directory} / docker, other files will be replicated resources element other than, for example, project jar file.

Copy the code
<!--docker-maven-plugin插件(带Dockerfile文件)-->
<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.13</version>
    <configuration>
        <imageName>${project.name}:${project.version}</imageName>
        <!--Dockerfile文件位置-->
        <dockerDirectory>docker</dockerDirectory>
        <resources>
            <resource>
                <targetPath>/</targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.jar</include>
            </resource>
        </resources>
    </configuration>
</plugin>
Copy the code

 

Second, the use

Create a mirror

mvn clean package docker:build

Push the mirror to Registry

mvn clean package docker:build -DpushImage

Tag to specify the mirror push Registry

mvn clean package docker:build -DpushImageTag

Third, Docker command to bind the various stages Maven

 

Guess you like

Origin www.cnblogs.com/jpfss/p/10945425.html