maven package docker:build - connection refused

后端 未结 10 2085
梦谈多话
梦谈多话 2021-02-07 05:06

I am trying to directly build a docker image with maven with mvn package docker:build.

Docker is running and docker ps shows me my containers,

相关标签:
10条回答
  • 2021-02-07 05:26

    i solve the problem using this setting:

    <configuration>
    	<imageName>10.10.8.175:5000/${artifactId}:${project.version}</imageName>
    	<dockerHost>https://192.168.99.100:2376</dockerHost>
    	<dockerCertPath>C:\Users\AtomView\.docker\machine\machines\default</dockerCertPath>
    	<dockerDirectory>src/main/resources/docker</dockerDirectory>
    	<resources>
    		<resource>
    			<targetPath>/</targetPath>
    			<directory>${project.build.directory}</directory>
    			<include>*.zip</include>
    		</resource>
    	</resources>
    </configuration>

    0 讨论(0)
  • 2021-02-07 05:34

    On Windows with Docker/Hyper-V this occurred to me with com.spotify:docker-maven-plugin:1.0.0. There is a discussion about this on another forum, where they advise to turn on

    in docker Settings/General Tab. It worked for me.

    0 讨论(0)
  • 2021-02-07 05:34

    On windows 7 64 the docker env seems a bit tricky to install as it requires a linuxVM to run (update issues with previous vbox installation) https://github.com/docker/machine/issues/3396 )

    Luckily in the docker quickstart terminal we can do:

       $ docker-machine.exe env
       export DOCKER_TLS_VERIFY="1"
       export DOCKER_HOST="tcp://192.168.99.101:2376"
       export DOCKER_CERT_PATH="C:\Users\uv\.docker\machine\machines\default"
       export DOCKER_MACHINE_NAME="default"
       # Run this command to configure your shell:
       # eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)
    

    showing us what to put into the plugin configuration

       <dockerHost>https://192.168.99.101:2376</dockerHost>
    

    but only after using the advice found here:

    Docker: An error occurred trying to connect

    with the important part being:

    Run FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO %i
    

    we can run the mvnw docker:build successfully in the cmd/intellij terminal :)

    0 讨论(0)
  • 2021-02-07 05:35

    On MacOs, I just set the environment variables as shown by

    docker-machine env

    When running the build from an IDE, make sure these variables are properly set.

    0 讨论(0)
  • 2021-02-07 05:35

    update maven docker plugin to latest version 1.2.0. This solves the problem.

    0 讨论(0)
  • 2021-02-07 05:37

    Below change fixed my issue on OSX El Capitan, Docker Version 1.12.1 (build: 12133):

    export DOCKER_HOST=unix:///var/run/docker.sock
    

    Please restart docker if mvn package docker:build still fails.

    0 讨论(0)
提交回复
热议问题