简体   繁体   中英

DOCKER_HOST environment variable on windows

I'm running Docker 1.12.0 on a Windows 10 machine. I'm developing a Java program, using Maven 3.3.9 as a dependency manager. I have a maven docker plugin ( https://github.com/fabric8io/docker-maven-plugin ), which gives the following error on clean install.

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.15.16:build (docker-build-start) on project integration-test: Execution docker-build-start of goal io.fabric8:docker-maven-plugin:0.15.16:build failed: No <dockerHost> or <machine> given, no DOCKER_HOST environment variable, and no read/writable '/var/run/docker.sock' -> [Help 1]

When I run a clean install with the following configuration option in the POM file:

<dockerHost>tcp://0.0.0.0:2376</dockerHost>

the following result is shown.

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.15.16:build (docker-build-start) on project integration-test: Cannot create docker access object: Cannot extract API version from server https://0.0.0.0:2376 : Connect to 0.0.0.0:2376 [/0.0.0.0] failed: Connection refused: connect -> [Help 1]

My question: is there an IP address I can use to tell this maven plugin where it can reach the daemon? Normal docker commands work perfectly fine. The plugin works without any problems on OS X.

On Windows 10 with Docker for Windows, the Docker Engine API is available in these two locations:

  • npipe:////./pipe/docker_engine
  • http://localhost:2375

I recommend trying with the localhost one.

Details here: https://docs.docker.com/docker-for-windows/faqs/#/how-do-i-connect-to-the-remote-docker-engine-api

It seems the user which is running Maven goals doesn't have access to docker.sock . The error message is telling which options are there to resolve the problem.

No <dockerHost> or <machine> given, no DOCKER_HOST environment variable, and no read/writable '/var/run/docker.sock '

Last option is the easiest one because it requires a file permission and it doesn't need to create any docker machine or set a DOCKER_HOST, On Linux you can change read/write permission of docker.sock with the following:

sudo chmod 776 /var/run/docker.sock

On windows go through this article : Microsoft article

After nearly a day of fruitless Googling I found this solution by myself. Trivial, but might still help others.

暴露 Docker 守护进程

You need to enable the checkbox 'Expose daemon on...' under Settings -> General

If someone just wants to skip fabric8 docker-maven-plugin execution that prevents build to succeed with error

No given, no DOCKER_HOST environment variable, no read/writable '/var/run/docker.sock' or '//./pipe/docker_engine' and no external provider like Docker machine configured

then this can be achieved with -Ddocker.skip=true according to https://dmp.fabric8.io/#global-configuration .

If you are using Window and Maven in eclipse to build your java project but continue seeing that error, then you have to perform these steps:

Step1:

You need to enable the checkbox 'Expose daemon on...' under Settings -> General As mentioned by @Adriaan Koster

If step1 does not solve the issue,then

Step2: Run your eclipse in administration mode. Now it should work without issues.

use docker-machine if you are using toolbox.

            <machine>
                <name>default</name>
                <autoCreate>true</autoCreate>
                <createOptions>
                    <driver>virtualbox</driver>
                    <virtualbox-cpu-count>2</virtualbox-cpu-count>
                </createOptions>
            </machine>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM