2017-11-05 2 views
1

ich dockerfile-Maven-Plugin mit der folgenden Konfiguration verwenden:Tagging geschaffenes Bild mit dockerfile-Maven-Plugin

<plugin> 
    <groupId>com.spotify</groupId> 
    <artifactId>dockerfile-maven-plugin</artifactId> 
    <version>1.3.6</version> 
    <executions> 
     <execution> 
      <id>build-image</id> 
      <goals> 
       <goal>build</goal> 
      </goals> 
      <configuration> 
       <tag>latest</tag> 
       <repository>root/${project.artifactId}</repository> 
       <buildArgs> 
        <APP_NAME>${project.artifactId}</APP_NAME> 
       </buildArgs> 
      </configuration> 
     </execution> 
     <execution> 
      <id>push-image</id> 
      <goals> 
       <goal>push</goal> 
      </goals> 
      <configuration> 
       <repository>${docker.registry.url}/root/${project.artifactId}</repository> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

Projekt Bereitstellung fehlschlägt durch:

[INFO] The push refers to a repository [my-repository:9090/root/image-name] 
[ERROR] An image does not exist locally with the tag: my-repository:9090/root/image-name 
[WARNING] An attempt failed, will retry 1 more times 
org.apache.maven.plugin.MojoExecutionException: Could not push image 
. 
. 
. 

das Repository unter dem Voranstellen Build-Ziel (ähnlich wie Push-Ziel) löst das Problem. Dann aber das lokal erstellte Bild, dem das Repository-Tag vorangestellt ist.

Keine Dokumentationsreferenz zur Ausführung des Tags vor Push-Task gefunden.

Mit anderen Worten, ich möchte, dass meine lokalen Docker Bilder 2 Bilder nach dem Plug-Ausführung enthalten:

REPOSITORY          TAG     IMAGE ID   CREATED    SIZE 
root/image-name         latest    7ac1144c607e  21 minutes ago  175MB 
my-repository:9090/root/image-name    latest    7ac1144c607e  21 minutes ago  175MB 

Meine Docker Version: 17.06.0-ce

Antwort

1

Hinzufügen zusätzlicher Ausführungsschritt zu meiner Konfiguration löste das Problem:

<execution> 
    <id>tag-image</id> 
    <phase>deploy</phase> 
    <goals> 
     <goal>tag</goal> 
    </goals> 
    <configuration> 
     <repository>${docker.registry.url}/root/${project.artifactId}</repository> 
    </configuration> 
</execution> 
0

Sie in issue 331 sehen ein Konfiguration, wo Sie den Tag in der Lage zu geben, sollten Sie auf docker build angewendet werden sollen:

<configuration> 
    <serverId>[repo-hostname]</serverId> 
    <registryUrl>https://[repo-hostname]:[repo-port]</registryUrl> 
    <imageName>[repo-hostname]:[repo-port]/xxx/yyy</imageName> 
    <dockerDirectory>${basedir}/src/docker</dockerDirectory> 
    <imageTags> 
     <imageTag>${project.version}</imageTag> 
     <imageTag>latest</imageTag> <==== replace that 
    </imageTags> 
</configuration> 

Wie in issue 262 erwähnt, y ou zusätzlich benötigen

docker:build -DpushImage -DpushImageTags