Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins and docker: uri was not specified

Tags:

docker

jenkins

I've installed docker, jenkins and docker-build-step in jenkins.

I've set an step in order to build an image from a Dockerfile of my repository.

It dumps me this message:

Started by BitBucket push by living_jordi
Started by BitBucket push by living_jordi
Building in workspace /var/lib/jenkins/workspace/Create Docker Images
Cloning the remote Git repository
Cloning repository [email protected]:livingdigital/docker-images.git
git init /var/lib/jenkins/workspace/Create Docker Images # timeout=10
Fetching upstream changes from [email protected]:livingdigital/docker-images.git
git --version # timeout=10
using GIT_SSH to set credentials BitBucket Private Key
git -c core.askpass=true fetch --tags --progress [email protected]:livingdigital/docker-images.git +refs/heads/*:refs/remotes/origin/*
git config remote.origin.url [email protected]:livingdigital/docker-images.git # timeout=10
git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
git config remote.origin.url [email protected]:livingdigital/docker-images.git # timeout=10
Fetching upstream changes from [email protected]:livingdigital/docker-images.git
using GIT_SSH to set credentials BitBucket Private Key
git -c core.askpass=true fetch --tags --progress [email protected]:livingdigital/docker-images.git +refs/heads/*:refs/remotes/origin/*
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 058ecd67befe53fb5e4d18e8103b955a1daadbe3 (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 058ecd67befe53fb5e4d18e8103b955a1daadbe3
First time build. Skipping changelog.
ERROR: Build step failed with exception
java.lang.NullPointerException: uri was not specified
  at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
  at com.github.dockerjava.core.DockerClientConfig$DockerClientConfigBuilder.withUri(DockerClientConfig.java:406)
  at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.createDockerClient(DockerBuilder.java:120)
  at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.getDockerClient(DockerBuilder.java:204)
  at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:68)
  at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
  at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
  at hudson.model.Build$BuildExecution.build(Build.java:205)
  at hudson.model.Build$BuildExecution.doRun(Build.java:162)
  at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
  at hudson.model.Run.execute(Run.java:1720)
  at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
  at hudson.model.ResourceController.execute(ResourceController.java:98)
  at hudson.model.Executor.run(Executor.java:410)
Build step 'Execute Docker command' marked build as failure

Any ideas?

EDIT This is my docker.service configuration file related with connection:

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock

Docker is listening to:

netstat -tupln | grep 4243
tcp        0      0 127.0.0.1:4243          0.0.0.0:*               LISTEN 

I've gone on Docker Builder configuration and I've set up Docker URL to http://127.0.0.1:4243. Test connection tells me:

Something went wrong, cannot connect to tcp://127.0.0.1:4243, cause: null

I've also made an request to the API REST using this command curl -XGET http://localhost:4243/containers/json and the results is right:

[
  {
    "Id":"27e79f6a504c5c5359630a30bc5c222b68bafaede774bd5462ac410dc0d34c36",
    "Names":[
      "/registry"
    ],
    "Image":"registry:2",
    "ImageID":"sha256:8ff6a4aae6575dace6b603626816e74e71e93aa54dfb670daff0a7426706e58c",
    "Command":"/bin/registry serve /etc/docker/registry/config.yml",
    "Created":1467798010,
    "Ports":[
      {
        "IP":"0.0.0.0",
        "PrivatePort":5000,
        "PublicPort":5000,
        "Type":"tcp"
      }
    ],
    "Labels":{

    },
    "State":"restarting",
    "Status":"Restarting (2) 10 hours ago",
    "HostConfig":{
      "NetworkMode":"default"
    },
    "NetworkSettings":{
      "Networks":{
        "bridge":{
          "IPAMConfig":null,
          "Links":null,
          "Aliases":null,
          "NetworkID":"",
          "EndpointID":"4c5a73c2ca7b9aeeff2384e0182e7b83a53cd1e7a9efd5fa416bb8c009b60568",
          "Gateway":"172.17.0.1",
          "IPAddress":"172.17.0.2",
          "IPPrefixLen":16,
          "IPv6Gateway":"",
          "GlobalIPv6Address":"",
          "GlobalIPv6PrefixLen":0,
          "MacAddress":"02:42:ac:11:00:02"
        }
      }
    },
    "Mounts":[
      {
        "Source":"/root/docker-registry/certs",
        "Destination":"/certs",
        "Mode":"",
        "RW":true,
        "Propagation":"rprivate"
      },
      {
        "Source":"/root/docker-registry/data",
        "Destination":"/var/lib/registry",
        "Mode":"",
        "RW":true,
        "Propagation":"rprivate"
      },
      {
        "Source":"/root/docker-registry/auth",
        "Destination":"/auth",
        "Mode":"",
        "RW":true,
        "Propagation":"rprivate"
      }
    ]
  }
]

I've also copied the log information when I click on Test Connection. The message is exactly the same despite of I've specified the uri:

Jul 07, 2016 7:22:04 AM FINE org.jenkinsci.plugins.dockerbuildstep.DockerBuilder
Trying to get client for http://127.0.0.1:4243 and version 
Jul 07, 2016 7:22:04 AM WARNING org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl
doTestConnection
uri was not specified java.lang.NullPointerException: uri was not specified     at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
  at com.github.dockerjava.core.DockerClientConfig$DockerClientConfigBuilder.withUri(DockerClientConfig.java:406)
  at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.createDockerClient(DockerBuilder.java:120)
  at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.getDockerClient(DockerBuilder.java:204)
  at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder$DescriptorImpl.doTestConnection(DockerBuilder.java:138)
  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.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:324)
  at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:167)  
  at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:100)
  at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124)     
  at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
  at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)    
  at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)   
  at org.kohsuke.stapler.MetaClass$5.doDispatch(MetaClass.java:233)     
  at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
  at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746)    
  at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)   
  at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)   
  at org.kohsuke.stapler.Stapler.service(Stapler.java:238)  
  at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)   
  at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669)
  at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135)
  at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:80)     
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
  at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
  at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
  at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
  at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
  at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)   
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
  at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652)
  at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
  at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553)
  at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223)
  at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
  at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
  at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
  at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
  at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
  at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
  at org.eclipse.jetty.server.Server.handle(Server.java:499)    
  at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)  
  at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257)
  at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
  at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
like image 821
Jordi Avatar asked Jul 05 '16 13:07

Jordi


1 Answers

With jenkins version of 2.51 and docker version 1.13.1, you can do the following to solve this issue. First add the following to the ExecStart (in docker.service):

ExecStart=/usr/bin/dockerd -H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock

And then go to Jenkins -> Manage Jenkins -> Configure system -> Docker builder. Here you specify:

tcp://127.0.0.1:4243

as Docker URL. Apply and Test connection.

like image 138
naimdjon Avatar answered Sep 21 '22 15:09

naimdjon