Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Docker for Mac #115

Open
bijoys opened this issue Jun 2, 2016 · 6 comments
Open

Support for Docker for Mac #115

bijoys opened this issue Jun 2, 2016 · 6 comments

Comments

@bijoys
Copy link

bijoys commented Jun 2, 2016

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.

@icksa
Copy link

icksa commented Jun 3, 2016

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

@wouterd
Copy link
Owner

wouterd commented Jun 6, 2016

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. :)

@bijoys
Copy link
Author

bijoys commented Jun 9, 2016

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

@rhuss
Copy link

rhuss commented Jun 9, 2016

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.

@bijoys
Copy link
Author

bijoys commented Jun 23, 2016

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

@udalrich
Copy link

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants