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

plugin refusing to use local unix sock for dockerd #474

Closed
NorrinRadd opened this issue Oct 4, 2017 · 13 comments
Closed

plugin refusing to use local unix sock for dockerd #474

NorrinRadd opened this issue Oct 4, 2017 · 13 comments
Assignees
Labels

Comments

@NorrinRadd
Copy link
Contributor

[workspace] $ /var/jenkins_home/jobs/platform-router-docker-build/workspace/gradlew clean pushToRegistry
Starting a Gradle Daemon, 2 busy Daemons could not be reused, use --status for details
:clean UP-TO-DATE
:buildImage
Building image using context '/var/jenkins_home/jobs/platform-router-docker-build/workspace'.
Using tag 'nimbus/platform-router' for image.
[dockerjava-jaxrs-async-0] INFO org.apache.http.impl.execchain.RetryExec - I/O exception (org.newsclub.net.unix.AFUNIXSocketException) caught when processing request to {}->unix://localhost:80: No such file or directory
[dockerjava-jaxrs-async-0] INFO org.apache.http.impl.execchain.RetryExec - Retrying request to {}->unix://localhost:80
[dockerjava-jaxrs-async-0] INFO org.apache.http.impl.execchain.RetryExec - I/O exception (org.newsclub.net.unix.AFUNIXSocketException) caught when processing request to {}->unix://localhost:80: No such file or directory

========================================================

// build.gradle

import com.github.jrubygradle.JRubyExec
import com.bmuschko.gradle.docker.tasks.container.*
import com.bmuschko.gradle.docker.tasks.image.*

buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.github.jruby-gradle:jruby-gradle-plugin:1.5.0'
classpath 'com.bmuschko:gradle-docker-plugin:3.2.0'
}
}

apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'com.github.jruby-gradle.base'
apply plugin: 'com.bmuschko.docker-remote-api'

dependencies {
jrubyExec 'rubygems:rspec:3.5.0'
jrubyExec 'rubygems:rest-client:2.0.2'
}

docker {
url = 'unix:///var/run/docker.sock'
certPath = null // I've tried with this line completely commented out also.

registryCredentials {
    url = 'https://docker-hub.glb.gapinc.com/artifactory/docker-non-prod/'
    username = ****
    password = ****
    email = '[email protected]'
}

}

task buildImage(type: DockerBuildImage) {
tag = 'stuff/platform-router'
inputDir = file('.')
}

task createMyAppContainer(type: DockerCreateContainer) {
dependsOn buildImage
targetImageId { buildImage.getImageId() }
portBindings = ['8080:80']
}

task startMyAppContainer(type: DockerStartContainer) {
dependsOn createMyAppContainer
targetContainerId { createMyAppContainer.getContainerId() }
}

task stopMyAppContainer(type: DockerStopContainer) {
targetContainerId { createMyAppContainer.getContainerId() }
}

task testNginxDocker(type : JRubyExec) {
dependsOn startMyAppContainer
workingDir './spec'
script 'rake'
finalizedBy stopMyAppContainer
}

task pushToRegistry(type: DockerPushImage) {
dependsOn testNginxDocker
imageName = { buildImage.getImageId() }
tag = { buildImage.getTag() }
}

==========================================

The job fails during the buildImage task. It seems like it's attempting to use HTTP with a unix syntax..... There are lots of reports of this happening on the docker maven plugin... I don't know if this plugin is somehow using some of the same src/libs as the docker maven plugin, but the bug seems to be exactly the same. Is this something that can be fixed? In my use case, changing how dockerd listens is not an option. We don't have full admin over the machine.

@cdancy cdancy self-assigned this Oct 4, 2017
@cdancy cdancy added the question label Oct 4, 2017
@cdancy
Copy link
Collaborator

cdancy commented Oct 4, 2017

@NorrinRadd if you're on a unix based system you can leave out the url property altogether as we will recognize you're on unix based system and just use unix:///var/run/docker.sock.

So here is what I would do: simplify your script down to the bare minimum to get things going ONLY for the build image task. Meaning: remove all the other tasks and dependencies and do something very simple that should "just work". Once we have that going (please post most simple reproducible snippet here) or not we can decide what to do next.

@NorrinRadd
Copy link
Contributor Author

Continued report: the daemon seems to be running perfectly fine:

$ netstat -a|grep docker
unix 2 [ ACC ] STREAM LISTENING 20259 /var/run/docker/libcontainerd/docker-containerd.sock
unix 2 [ ACC ] STREAM LISTENING 22368 /run/docker/libnetwork/7c64002508c53b2a77f2dd5569347ad3047e751f6b2b5c9db618bf7477ce42f5.sock
unix 2 [ ACC ] STREAM LISTENING 20913 /var/run/docker.sock
unix 3 [ ] STREAM CONNECTED 21645 /var/run/docker/libcontainerd/docker-containerd.sock

$ curl --unix-socket /var/run/docker.sock -X POST http:/v1.24/containers/1c6594faf5/start
{"message":"No such container: 1c6594faf5"}

Similar Reports

spotify/docker-maven-plugin#221
spotify/docker-maven-plugin#183
spotify/docker-maven-plugin#192
https://stackoverflow.com/questions/34748584/what-is-happening-when-docker-maven-plugin-tries-to-build-image
[stopping here, in order to ready cdandy's reply]

@NorrinRadd
Copy link
Contributor Author

@cdancy
The plugin attempts to use http and a port when url is removed

[Gradle] - Launching build.
[workspace] $ /var/jenkins_home/jobs/platform-router-docker-build/workspace/gradlew clean pushToRegistry
Starting a Gradle Daemon, 2 busy Daemons could not be reused, use --status for details
:clean UP-TO-DATE
:buildImage
Building image using context '/var/jenkins_home/jobs/platform-router-docker-build/workspace'.
Using tag 'nimbus/platform-router' for image.
[dockerjava-jaxrs-async-0] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
org.apache.http.conn.HttpHostConnectException: Connect to 127.0.0.1:2375 [/127.0.0.1] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)

@cdancy
Copy link
Collaborator

cdancy commented Oct 4, 2017

Are you running this script in a standalone environment or as part of bigger build? What environment are you running this on? Is it virtual?

@NorrinRadd
Copy link
Contributor Author

This is running on a jenkins server. It's a standalone job. It's RHELinux.

@cdancy
Copy link
Collaborator

cdancy commented Oct 4, 2017

hmmm ... do you have other machines where docker is installed where this does work? Just trying to figure out where your issue lies. Do you have a bare-bones snippet with all the extra stuff removed that someone could run?

@orzeh
Copy link
Collaborator

orzeh commented Oct 4, 2017

@NorrinRadd maybe in your CI environment DOCKER_HOST variable is set?

@NorrinRadd
Copy link
Contributor Author

Hmm we seem to have found the problem. The jenkins server is running in a docker container. The job gets a lot further when run locally. @cdancy

@NorrinRadd
Copy link
Contributor Author

Where's a better place to get support for this plugin than creating issues here? (assuming the problem is not a bug or feature request)

@cdancy
Copy link
Collaborator

cdancy commented Oct 4, 2017

Aaahhh got it. We use cloudbees Jenkins here and pass along the host socket url as an environment variable to the dockerized Jenkins server. We then reference that env-var and pass it along to the plugin.

@orzeh
Copy link
Collaborator

orzeh commented Oct 4, 2017

Where's a better place to get support for this plugin than creating issues here? (assuming the problem is not a bug or feature request)

@NorrinRadd You can join us on Gitter https://gitter.im/gradle-docker-plugin/Lobby

@cdancy
Copy link
Collaborator

cdancy commented Oct 4, 2017

We may not be IN the lobby but we'll get emails if you ping us there.

@NorrinRadd
Copy link
Contributor Author

Ok. I posted over there.

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

No branches or pull requests

3 participants