title: Maven Docker Plugin Connection refused
body: <p>I am using this maven docker plugin</p>
  
  <p><a href="https://github.com/wouterd/docker-maven-plugin" rel="nofollow">https://github.com/wouterd/docker-maven-plugin</a></p>
  
  <p>My pom.xml file looks like </p>
  
  <pre><code>            &lt;plugin&gt;
              &lt;groupId&gt;net.wouterdanes.docker&lt;/groupId&gt;
              &lt;artifactId&gt;docker-maven-plugin&lt;/artifactId&gt;
              &lt;version&gt;5.0.0&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;package&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;build-images&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;images&gt;
                              &lt;image&gt;
                                  &lt;id&gt;cloudera&lt;/id&gt;
                                  &lt;dockerFile&gt;${project.basedir}/src/integration-test/docker/Dockerfile&lt;/dockerFile&gt;
                                  &lt;artifacts&gt;
                                      &lt;artifact&gt;
                                          &lt;file&gt;${project.build.directory}/${project.build.finalName}.jar&lt;/file&gt;
                                      &lt;/artifact&gt;
                                  &lt;/artifacts&gt;
                              &lt;/image&gt;
                          &lt;/images&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;start&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;start-containers&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;!-- You can set forceCleanup to true to stop and remove started containers
                               at the end of the build even if the stop-containers goal is not executed
                               (useful for preventing Ctrl+C causing dangling containers) --&gt;
                          &lt;forceCleanup&gt;true&lt;/forceCleanup&gt;
                          &lt;containers&gt;
                              &lt;container&gt;
                                  &lt;id&gt;cloudera&lt;/id&gt;
                                  &lt;image&gt;cloudera/quickstart&lt;/image&gt;                                    
                                  &lt;waitForStartup&gt;Cloudera started for&lt;/waitForStartup&gt;
                              &lt;/container&gt;
                          &lt;/containers&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;stop&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;stop-containers&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;verify&lt;/id&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;verify&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>when I run my build using <code>mvn verify -e -X</code> I get error</p>
  
  <pre><code>    ERROR] Failed to execute goal net.wouterdanes.docker:docker-maven-plugin:5.0.0:build-images (package) on project SparkIntegrationTest: Execution package of goal net.wouterdanes.docker:docker-maven-plugin:5.0.0:build-images failed: java.net.ConnectException: Connection refused -&gt; [Help 1]
  org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal net.wouterdanes.docker:docker-maven-plugin:5.0.0:build-images (package) on project SparkIntegrationTest: Execution package of goal net.wouterdanes.docker:docker-maven-plugin:5.0.0:build-images failed: java.net.ConnectException: Connection refused
      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: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 package of goal net.wouterdanes.docker:docker-maven-plugin:5.0.0:build-images failed: java.net.ConnectException: Connection refused
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
      ... 20 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:130)
      at net.wouterdanes.docker.provider.RemoteApiBasedDockerProvider.buildImage(RemoteApiBasedDockerProvider.java:99)
      at net.wouterdanes.docker.maven.BuildImageMojo.doExecute(BuildImageMojo.java:60)
      at net.wouterdanes.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:120)
      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
      ... 21 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.&lt;init&gt;(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)
  </code></pre>
  
  <p>The thing I don't understand is "connection refused to what"? which resource is not connectable? if I knew perhaps I could have troubleshooted this.</p>