docker-maven-plugin icon indicating copy to clipboard operation
docker-maven-plugin copied to clipboard

Support for Docker for Mac

Open bijoys opened this issue 8 years ago • 6 comments

This plugin is failing to build images when used with Docker for Mac. The error is 'java.net.ConnectException: Connection refused'. DOCKER_HOST is set to unix:///var/run/docker.sock

Is there a way to get the plugin working for Docker for Mac?

thanks.

bijoys avatar Jun 02 '16 23:06 bijoys

+1, I was able to build an image using Docker for Mac using the spotify docker maven plugin

icksa avatar Jun 03 '16 14:06 icksa

Hmm, interesting. I have docker or mac as well, but it doesn't set the DOCKER_HOST environment variable and thus my plugin just works. Try it by doing unset DOCKER_HOST before running the maven build. Docker 4 mac exposes the socket as well as an http interface to the docker daemon on localhost, so the default behaviour of my plugin (connecting to http on localhost) should do. Support for unix domain sockets is something I'd love to have, but it's rather hard on the JVM to get it to work. Also, I'd have to figure out how to change the transport of my http client from tcp to unix sockets, which isn't all that trivial. :)

wouterd avatar Jun 06 '16 14:06 wouterd

Thanks for the response. I did not have DOCKER_HOST env variable set when I tested this. My docker command line is working fine, but the plugin fails with connection refused. Please see the stack trace below. Is there anything I can do to troubleshoot this further?

[ERROR] Failed to execute goal net.wouterdanes.docker:docker-maven-plugin:4.2.1:build-images (build) on project ingest-docker: Execution build of goal net.wouterdanes.docker:docker-maven-plugin:4.2.1:build-images failed: java.net.ConnectException: Connection refused -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.wouterdanes.docker:docker-maven-plugin:4.2.1:build-images (build) on project ingest-docker: Execution build of goal net.wouterdanes.docker:docker-maven-plugin:4.2.1:build-images failed: java.net.ConnectException: Connection refused
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    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:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    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:497)
    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)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution build of goal net.wouterdanes.docker:docker-maven-plugin:4.2.1:build-images failed: java.net.ConnectException: Connection refused
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: javax.ws.rs.ProcessingException: java.net.ConnectException: Connection refused
    at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:229)
    at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:246)
    at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
    at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
    at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424)
    at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333)
    at net.wouterdanes.docker.remoteapi.MiscService.buildImage(MiscService.java:115)
    at net.wouterdanes.docker.provider.RemoteApiBasedDockerProvider.buildImage(RemoteApiBasedDockerProvider.java:100)
    at net.wouterdanes.docker.maven.BuildImageMojo.doExecute(BuildImageMojo.java:60)
    at net.wouterdanes.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:108)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    ... 20 more
Caused by: java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:175)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
    at sun.net.www.http.HttpClient.New(HttpClient.java:308)
    at sun.net.www.http.HttpClient.New(HttpClient.java:326)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1168)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1104)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:998)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:932)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1282)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1257)
    at org.glassfish.jersey.client.HttpUrlConnector$3.getOutputStream(HttpUrlConnector.java:312)
    at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:200)
    at org.glassfish.jersey.message.internal.CommittingOutputStream.commitStream(CommittingOutputStream.java:194)
    at org.glassfish.jersey.message.internal.CommittingOutputStream.write(CommittingOutputStream.java:213)
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$UnCloseableOutputStream.write(WriterInterceptorExecutor.java:294)
    at org.glassfish.jersey.message.internal.ByteArrayProvider.writeTo(ByteArrayProvider.java:96)
    at org.glassfish.jersey.message.internal.ByteArrayProvider.writeTo(ByteArrayProvider.java:60)
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:265)
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
    at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
    at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1154)
    at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:503)
    at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:315)
    at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227)
    ... 35 more

bijoys avatar Jun 09 '16 18:06 bijoys

Support for unix domain sockets is something I'd love to have, but it's rather hard on the JVM to get it to work. Also, I'd have to figure out how to change the transport of my http client from tcp to unix sockets, which isn't all that trivial. :)

@wouterd its not so super difficult, all you need to todo is to use a different ConnectionSocketFactory for unix sockets like it is done here for Apache HttpClient.

I first thought, too, that it is too difficult, but its astonishingly easy (Spotify does it quite similarly).

And btw, Docker for Mac over Unix sockets works really nice.

rhuss avatar Jun 09 '16 20:06 rhuss

@wouterd would you be able to integrate the changes suggested by @rhuss? Thanks.

bijoys avatar Jun 23 '16 17:06 bijoys

I am running Docker 1.12 and it does not seem to be opening the socket at 2375.

$ telnet localhost 2375 Trying 127.0.0.1... telnet: connect to address 127.0.0.1: Connection refused Trying ::1... telnet: connect to address ::1: Connection refused telnet: Unable to connect to remote host $ docker --version Docker version 1.12.0-rc3, build 91e29e8, experimental $ echo $DOCKER_HOST

(That is an empty line as the echo output).

udalrich avatar Aug 25 '16 15:08 udalrich