Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on image names with more than three path elements #694

Closed
jbonevich opened this issue Jan 23, 2017 · 3 comments
Closed

Build fails on image names with more than three path elements #694

jbonevich opened this issue Jan 23, 2017 · 3 comments
Labels

Comments

@jbonevich
Copy link

jbonevich commented Jan 23, 2017

Description

If my docker image has more than three path elements (e.g. "some.docker.repository.com/user/path1/path2/path3/my-test-image"), I get the following error:

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.19.0:build (build) on project docker-fabric8-test: Execution build of goal io.fabric8:docker-maven-plugin:0.19.0:build failed: Given repository name 'some.docker.repository.com/user/path1/path2/path3/my-test-image:latest' is invalid:
[ERROR] * image part 'path1/path2/path3/my-test-image' doesn't match allowed pattern '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?[a-z0-9]+(?:(?:[._]|__|[-]*)[a-z0-9]+)*(?:/[a-z0-9]+(?:(?:[._]|__|[-]*)[a-z0-9]+)*)?'
[ERROR] See http://bit.ly/docker_image_format for more details

Note that the regex above seems to support an optional host name

 ('(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])(?:(?:\.(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]))+)?(?::[0-9]+)?/)?') 

followed by a single name component, followed by an optional slash and single name component. I do not understand the use of the host name component, but that would match 'path1/' in my example; the single component would match 'path2', and the optional slash-and-name component matches '/path3'. The match then fails on the trailing '/my-test-image.

I have tested building an image with this name from the docker command line with success. I ran my example with an image name of 'some.docker.repository.com/user/path1/path2/my-test-image' and it runs successfully.

Also, please note that the link to http://bit.ly/docker_image_format is dead.

Info

  • d-m-p version : 0.19.0
  • Maven version (mvn -v) :
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T11:41:47-05:00)
Maven home: /Users/bonevij/maven
Java version: 1.8.0_72, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.5", arch: "x86_64", family: "mac"
  • Docker version :
    Docker version 1.12.6, build 78d1802

  • If it's a bug, how to reproduce :
    Create a POM file with the docker-maven-plugin and image name with three or more path elements after a repository and user name and before the image element.

  • If it's a feature request, what is your use case :

  • Sample project : [GitHub Clone URL]

@jbonevich
Copy link
Author

jbonevich commented Jan 23, 2017

Content of my 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>

    <groupId>com.thermofisher.cloud</groupId>
    <artifactId>docker-fabric8-test</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <build>
        <plugins>
            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.19.0</version>
                <configuration>
                    <images>
                        <image>
                            <name>some.docker.repository.com/user/path1/path2/path3/my-test-image</name>
                            <build>
                                <dockerFileDir>.</dockerFileDir>
                            </build>
                        </image>
                    </images>
                </configuration>
                <executions>
                    <execution>
                        <id>build</id>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <phase>install</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Content of src/main/docker/Dockerfile:

FROM alpine
ENV HOME /root
WORKDIR /root
CMD ["bash"]

@rhuss
Copy link
Collaborator

rhuss commented Feb 16, 2017

It could be that Docker changed the regexp for new versions of Docker, I have to verify this.

However the regular expression above does allow only a fixed number of element in the format //: with all of them being optional, and as the only mandatory component must match [a-z0-9]+ (so no additional / allowed here).

I will verify whether this is still the proper regexp for the latest Docker versions and also fix the link to the documentation.

@rhuss
Copy link
Collaborator

rhuss commented Mar 19, 2017

You are right multiple segments in the name are allowed these days. Going to fix this.

@rhuss rhuss added the bug label Mar 19, 2017
rgbj pushed a commit to rgbj/docker-maven-plugin that referenced this issue Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants