Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

build failed: Host name may not be null #890

Closed
gr33npr opened this issue Sep 13, 2017 · 7 comments · Fixed by #903
Closed

build failed: Host name may not be null #890

gr33npr opened this issue Sep 13, 2017 · 7 comments · Fixed by #903

Comments

@gr33npr
Copy link

gr33npr commented Sep 13, 2017

Description

While building a docker-image, which included the dockerfile-maven-plugin > 1.3.1 and an activated proxy in mavens setting.xml, the build will fail with the fhe following message:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.4:build (default) on project XXXXX: Execution default of goal com.spotify:dockerfile-maven-plugin:1.3.4:build failed: Host name may not be null

If i remove the proxy-part or use an older version of dockerfile-maven-plugin, everything is fine. I`ve read that dockerfile-maven-plugin is using docker-client 8.8.X instead 8.7.X which added proxy-support, so i thought it could be

How to reproduce

Define a pom which includes dockerfile-maven-plugin/docker-client, define "build" as goal and set a proxy in mavens settings.xml

What do you expect

BUILD SUCCESS

What happened instead

BUILD FAILED

Software:

  • docker version: [Add the output of docker version here, both client and server]
  • Spotify's docker-client version: [Add docker-client version here]

Full backtrace

com.spotify:dockerfile-maven-plugin:1.3.4:build failed: Host name may not be null
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
	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:84)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
	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:290)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:414)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:357)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal com.spotify:dockerfile-maven-plugin:1.3.4:build failed: Host name may not be null
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
	... 19 more
Caused by: java.lang.IllegalArgumentException: Host name may not be null
	at org.apache.http.util.Args.containsNoBlanks(Args.java:81)
	at org.apache.http.HttpHost.<init>(HttpHost.java:81)
	at org.glassfish.jersey.apache.connector.ApacheConnector.<init>(ApacheConnector.java:255)
	at org.glassfish.jersey.apache.connector.ApacheConnectorProvider.getConnector(ApacheConnectorProvider.java:115)
	at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:425)
	at org.glassfish.jersey.client.ClientConfig$State.access$000(ClientConfig.java:90)
	at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:122)
	at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:119)
	at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:340)
	at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:733)
	at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:286)
	at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:135)
	at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:105)
	at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:101)
	at org.glassfish.jersey.client.JerseyInvocation.<init>(JerseyInvocation.java:92)
	at org.glassfish.jersey.client.JerseyInvocation$AsyncInvoker.method(JerseyInvocation.java:620)
	at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:2441)
	at com.spotify.docker.client.DefaultDockerClient.version(DefaultDockerClient.java:501)
	at com.spotify.docker.client.DefaultDockerClient.authRegistryHeader(DefaultDockerClient.java:2555)
	at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1396)
	at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:1365)
	at com.spotify.plugin.dockerfile.BuildMojo.buildImage(BuildMojo.java:177)
	at com.spotify.plugin.dockerfile.BuildMojo.execute(BuildMojo.java:105)
	at com.spotify.plugin.dockerfile.AbstractDockerMojo.tryExecute(AbstractDockerMojo.java:227)
	at com.spotify.plugin.dockerfile.AbstractDockerMojo.execute(AbstractDockerMojo.java:216)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
	... 20 more

@mattnworb
Copy link
Member

Looking at the stacktrace, I would guess the issue is not so much a proxy server but the value being used for DOCKER_HOST. What does your DOCKER_HOST environment variable, and could you attach output from running the same maven command with -X?

@gr33npr
Copy link
Author

gr33npr commented Sep 14, 2017

Hello mattnworb,

thx for your reply. This is already the output of "mvn clean package -e -X". I have set the DOCKER_HOST env to 127.0.0.1:2375, where docker is listening(checked with netstat/telnet). Also set the dockerHost via my pom.xml doesn`t help.
As i mentioned above, the buildprocess will success if i remove the proxy from setting.xml, so i think the DOCKER_HOST-envvar is okay. Am i right?

@ManishAgrawal1410
Copy link

@mattnworb
Hi Matt,
I am using this library in one of my project. I want to use docker-client version 6.1.1, which is latest stable release. But the problem is, Documentation (user manual) is written according to 3.5.4. So I am getting problems in integrating 6.1.1. Can you please provide me some user manual of 6.1.1. This will be a great help for me. Thanks in advance.

@gokhansari
Copy link

I have also same issue with dockerfile-maven plugin. Docker for mac does not set any DOCKER_HOST env. Any idea about it?

@drallgood
Copy link

Any chance you guys are behind a corporate proxy?
I encountered the same issue and figured out that the proxy settings of macOS are the culprit.
No idea how to solve this yet, but the issue is that the string is localhost:3128 instead of http://localhost:3128 which causes the URI to not get parsed correctly

@deki
Copy link
Contributor

deki commented Oct 17, 2017

The problem is in:

config.property(ClientProperties.PROXY_URI, proxyHost + ":"

The proxy url is combined using http.proxyHost and http.proxyPort. https://github.com/jersey/jersey/blob/master/connectors/apache-connector/src/main/java/org/glassfish/jersey/apache/connector/ApacheConnector.java#L261 requires to also add http://. Moreover https.proxyHost and https.proxyPort should be honored as well.

deki pushed a commit to deki/docker-client that referenced this issue Oct 17, 2017
deki added a commit to deki/docker-client that referenced this issue Oct 17, 2017
@davidxia
Copy link
Contributor

@drallgood @gokhansari @gr33npr Does #903 fix your issue?

mattnworb added a commit that referenced this issue Dec 19, 2017
deki added a commit to deki/docker-client that referenced this issue Jan 25, 2018
deki added a commit to deki/docker-client that referenced this issue Jan 25, 2018
davidxia added a commit that referenced this issue Jan 30, 2018
#890 fix for proxy usage ("Expected authority at index 7" error)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants