Docker-maven-plugin: Use connect timeout for Named Pipes

Created on 8 May 2018  路  12Comments  路  Source: fabric8io/docker-maven-plugin

At least on Windows, the plugin frequently logs retry attempts when connecting to the docker host via named pipes:

[INFO] I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://127.0.0.1:1: \\.\pipe\docker_engine (all pipe instances are busy)
[INFO] Retrying request to {}->npipe://127.0.0.1:1
[INFO] I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://127.0.0.1:1: \\.\pipe\docker_engine (all pipe instances are busy)
[INFO] Retrying request to {}->npipe://127.0.0.1:1
[INFO] I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://127.0.0.1:1: \\.\pipe\docker_engine (all pipe instances are busy)
[INFO] Retrying request to {}->npipe://127.0.0.1:1
[ERROR] DOCKER> Cannot create docker access object  [Cannot extract API version from server npipe://127.0.0.1:1 : \\.\pipe\docker_engine (all pipe instances are busy)]

The build then fails with this exception:

[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.25.2:start (start) on project geo-persistence: Cannot create docker access object: Cannot extract API version from server npipe://127.0.0.1:1 : \\.\pipe\docker_engine (all pipe instances are busy) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.fabric8:docker-maven-plugin:0.25.2:start (start) on project geo-persistence: Cannot create docker access object 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
Caused by: org.apache.maven.plugin.MojoExecutionException: Cannot create docker access object 
    at io.fabric8.maven.docker.service.DockerAccessFactory.createDockerAccess(DockerAccessFactory.java:52)
    at io.fabric8.maven.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:219)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 21 more
Caused by: io.fabric8.maven.docker.access.DockerAccessException: Cannot extract API version from server npipe://127.0.0.1:1 : \\.\pipe\docker_engine (all pipe instances are busy)
    at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.getServerApiVersion(DockerAccessWithHcClient.java:105)
    at io.fabric8.maven.docker.service.DockerAccessFactory.createDockerAccess(DockerAccessFactory.java:45)
    ... 24 more
Caused by: java.io.FileNotFoundException: \\.\pipe\docker_engine (all pipe instances are busy)
    at java.io.RandomAccessFile.open0(Native Method)
    at java.io.RandomAccessFile.open(RandomAccessFile.java:316)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:124)
    at io.fabric8.maven.docker.access.hc.win.NamedPipe.connect(NamedPipe.java:59)
    at io.fabric8.maven.docker.access.hc.util.AbstractNativeSocketFactory.connectSocket(AbstractNativeSocketFactory.java:42)
    at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
    at org.apache.http.impl.conn.BasicHttpClientConnectionManager.connect(BasicHttpClientConnectionManager.java:323)
    at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:221)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
    at io.fabric8.maven.docker.access.hc.ApacheHttpClientDelegate.get(ApacheHttpClientDelegate.java:67)
    at io.fabric8.maven.docker.access.hc.DockerAccessWithHcClient.getServerApiVersion(DockerAccessWithHcClient.java:101)
    ... 25 more

In my case, this happens when a build execution is directly followed by a start execution.

The connect timeout that is passed to io.fabric8.maven.docker.access.hc.win.NamedPipe#connect(java.net.SocketAddress, int) is 0. Apart from that, the parameter is not even used here. So the retries carried out by the Apache HttpClient happen instantly and show no effect. In contrast, if I wait 10-20 seconds and execute the plugin again, it usually works. So I guess this would just require some waiting time in between retries in order to work.

Most helpful comment

this did the trick for us in the configuration section:
<dockerHost>tcp://localhost:2375</dockerHost>
(note tcp instead of http as my docker exposes its proper daemon)

All 12 comments

I have very same problem.

Stacktrace:

[INFO] --- docker-maven-plugin:0.27.2:start (start) @ xyz ---
[INFO] DOCKER> [mysql:5.6.41] "mysql": Start container 253d2a6417cb
[INFO] DOCKER> [mysql:5.6.41] "mysql": Pausing for 8000 ms
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:prepare-agent-integration (agent-for-it) @ xyz ---
[INFO] argLine set to -javaagent:C:\\Users\\abc\\.m2\\repository\\org\\jacoco\\org.jacoco.agent\\0.7.8\\org.jacoco.agent-0.7.8-runtime.jar=destfile=C:\\Users\\abc\\xyz\\target\\jacoco-it.exec,append=true
[INFO]
[INFO] --- maven-failsafe-plugin:2.22.0:integration-test (default) @ xyz ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- docker-maven-plugin:0.27.2:stop (stop) @ xyz ---
pa? 16, 2018 1:44:58 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://127.0.0.1:1: \\.\pipe\docker_engine (All pipe instances are busy)
pa? 16, 2018 1:44:58 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->npipe://127.0.0.1:1
pa? 16, 2018 1:44:58 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://127.0.0.1:1: \\.\pipe\docker_engine (All pipe instances are busy)
pa? 16, 2018 1:44:58 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->npipe://127.0.0.1:1
pa? 16, 2018 1:44:58 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.FileNotFoundException) caught when processing request to {}->npipe://127.0.0.1:1: \\.\pipe\docker_engine (All pipe instances are busy)
pa? 16, 2018 1:44:58 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->npipe://127.0.0.1:1
[ERROR] DOCKER> Cannot create docker access object  [Cannot extract API version from server npipe://127.0.0.1:1 : \\.\pipe\docker_engine (All pipe instances are busy)]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:06 min
[INFO] Finished at: 2018-10-16T13:44:58+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.27.2:stop (stop) on project xyz: Cannot create docker access object: Cannot extract API version from server npipe://127.0.0.1:1 : \\.\pipe\docker_engine (All pipe instances are busy) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

  • d-m-p version :
0.27.2
  • Maven version (mvn -v) :
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)
Maven home: C:\Program Files\apache-maven-3.5.4\bin\..
Java version: 9.0.4, vendor: Oracle Corporation, runtime: C:\Program Files\openjdk-9.0.4_windows-x64_bin\jdk-9.0.4
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  • Docker version :
Version 18.06.1-ce-win73 (19507)
Channel: stable
b0f14f1

Same here on Windows. How to fix?

I also see this, on Windows 10.

You may try setting dockerHost like <dockerHost>http://localhost:2375</dockerHost>

Sprry, I'm really not a Windows expert. I wonder whether there is a limitation how many parallel request can be performed on NamedPipe (which is used to access the Windows Docker daemon).

Any Window expert out there able to help in fixing this issue ?

You may try setting dockerHost like <dockerHost>http://localhost:2375</dockerHost>

Could you specify a bit more where in the pom.xml to include this setting? It looks promising but as a maven semi-newbie, it's a bit hard to guess. A websearch didn't help me much either. Pretty please?

You can do this within the configuration.

<build>
    <plugins>
        <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>

            <configuration>
                <dockerHost>http://localhost:2375</dockerHost>
                <!-- ... -->
            </configuration>
        </plugin>
    </plugins>
</build>

See also the documentation:
http://dmp.fabric8.io/#global-configuration

this did the trick for us in the configuration section:
<dockerHost>tcp://localhost:2375</dockerHost>
(note tcp instead of http as my docker exposes its proper daemon)

Thanks, the configuration with TCP helped me as well. Just wanted to mention that you also need to enable TCP in your settings. In Docker Desktop(Windows) its possible to enable it under "General".

I have also reproduced this issue in Windows 10 and version 0.33.0.
It seems that workaround does the trick but as mentioned above it has to be manually enabled in Docker Desktop settings.
It would be great if this could be fixed by properly handling timeout values as suggested by @Mobe91

In particular, this is a blocker when running in the Windows virtual environment provided by GitHub Actions, where the TCP setting cannot be changed (or at least I'm unable to).
By the way, reducing the number of maxConnections does not help either...

I tried tcp 2375 and both http and https options and all failed for me. I have two builds back to back which shouldn't be a problem but fails every time with the named pipe issue. Being able to control some kind of delay between executions would be stellar, or even just a pause for each execution, period. I bet 1s would be enough.

Was this page helpful?
0 / 5 - 0 ratings