1

I am new to Docker. I installed Docker tool box on my Windows machine.

Using pom.xml I want to generate docker image . pom.xml:-


<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.4.11</version>
    <configuration>
        <repository>${docker.image.prefix}/${project.artifactId}</repository>
        <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
        <dockerDirectory>${project.basedir}/src/docker</dockerDirectory>
        <dockerHost>https://192.168.99.102:2376</dockerHost>
        <dockerCertPath>C:/Users/shridhar/.docker/machine/machines/default</dockerCertPath>
        <forceTags>true</forceTags>
        <imageTags>
            <imageTag>${projectVersion}</imageTag>
            <imageTag>latest</imageTag>
        </imageTags>

        <!-- push the image on docker hub -->
        <serverId>docker-hub</serverId>
        <registryUrl>https://hub.docker.com</registryUrl>
        <resources>
            <resource>
                <!-- war file locaion wheere war should be present (copied) -->
                <targetPath>/   </targetPath>
                <directory>${project.build.directory}</directory>
                <include>${project.build.finalName}.war</include>
            </resource>
        </resources>
    </configuration>
</plugin>

Docker machine details

$ env | grep 'DOCKER'
DOCKER_HOST=tcp://192.168.99.102:2376
DOCKER_MACHINE_NAME=default
DOCKER_TLS_VERIFY=1
DOCKER_TOOLBOX_INSTALL_PATH=C:\Program Files\Docker Toolbox
DOCKER_CERT_PATH=C:\Users\shridhar\.docker\machine\machines\default

I get the below exception:

Caused by: com.spotify.docker.client.exceptions.DockerException: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.client.ClientProtocolException

If I make tcp connection

<dockerHost>tcp://192.168.99.102:2376</dockerHost>

then I get below exception:

Caused by: java.lang.IllegalArgumentException: An HTTPS URI for DOCKER_HOST must be provided to use Docker client certificates

What changes do I have to make to build image sucessfully?

1

Considering you say you want to build an image (and not push it to Docker hub or wherever):

docker-maven-plugin project recommends using dockerfile-maven for new projects, as the former

[...] ultimately led to a lot of unnecessary confusion with our users that stemmed from introducing extra abstractions and a need for configuration on top of what Docker is providing.

The dockerfile-maven README should get you started, with both a sample Dockerfile and the relevant plugin section for your pom.xml

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.