Closed bitsofinfo closed 7 years ago
This definitely aids the issue
brew install socat
nohup socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock &
or /var/tmp/docker.sock (depends on your local setup)
@bitsofinfo this is definitely a known issue and the link to the docker-forum, and subsequently the docker-devs themselves, suggest that a "tcp fix" may not be forthcoming at all. Not sure what to make of that. The fix, as you note, does work as expected! Being a mac user myself I greatly appreciate you sharing this!
However, I've stumbled upon a few issues related to docker-on-mac being on v1.24 of their API and docker-java not yet supporting this. Trying to set the apiVersion
to 1.23, 1.22, 1.21 still was throwing exceptions. I've commented on an open issue they have already which is similar. Lets see what they have to say.
related #231 ?
Somewhat related but that is more ties to using Unix sockets than going over tcp. If we can get tcp working OOTB that would be the preferred solution and one we could move forward with instead of waiting on all the work that needs to be done to get Unix sockets on Mac working as expected.
I had Docker for Mac 1.11 working using this recipe:
dependencies {
dockerJava 'com.github.docker-java:docker-java:3.0.0'
dockerJava 'com.kohlschutter.junixsocket:junixsocket-common:2.0.4' // for gradle-docker-plugin using Unix sockets
dockerJava 'com.kohlschutter.junixsocket:junixsocket-native-common:2.0.4' // for gradle-docker-plugin using Unix sockets
dockerJava 'org.slf4j:slf4j-simple:1.7.5'
dockerJava 'cglib:cglib:3.2.0'
}
docker {
url = "unix:///var/run/docker.sock"
}
Docker for Mac 1.12 broke with the server API compatibility. At which point I uninstalled and am using docker-machine exclusively.
Force upgrading Docker Java's unix-socket-factory
dependency worked for me. Using Docker for Mac 1.12.0-a (stable) and docker-java-application 3.0.2.
configurations {
dockerJava {
resolutionStrategy {
force 'de.gesellix:unix-socket-factory:2016-04-06T22-21-19'
}
}
}
docker {
url = 'unix:///var/run/docker.sock'
}
@tclift great find ... but without digging into it: shure it's @gesellix's de.gesellix:unix-socket-factory (gesellix/unix-socket-factory) but not de.gesellix:docker-socket-factory (gesellix/docker-socket-factory)?
The docker-java lib depends on unix-socket-factory
, which is actually the one depending on the relevant com.kohlschutter.junixsocket:junixsocket*
libs.
Beware of Netty, though, as mentioned here: https://github.com/docker-java/docker-java/issues/537#issuecomment-206712757
@tclift I tried your suggestion and it led me to another exception. I tried running as sudo as well.
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':buildImage'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45)
at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:52)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38)
at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: net.sf.cglib.proxy.UndeclaredThrowableException: java.lang.reflect.InvocationTargetException-->null
at com.github.dockerjava.core.command.BuildImageResultCallback$$EnhancerByCGLIB$$3c8bede6.awaitImageId(<generated>)
at com.github.dockerjava.core.command.BuildImageResultCallback$$EnhancerByCGLIB$$3c8bede6$awaitImageId.call(Unknown Source)
at com.github.dockerjava.core.command.BuildImageResultCallback$$EnhancerByCGLIB$$20a8d4c6$awaitImageId.call(Unknown Source)
at com.bmuschko.gradle.docker.tasks.image.DockerBuildImage.runRemoteCommand(DockerBuildImage.groovy:119)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask$_start_closure1.doCall(AbstractDockerRemoteApiTask.groovy:48)
at com.bmuschko.gradle.docker.utils.DockerThreadContextClassLoader.withClasspath(DockerThreadContextClassLoader.groovy:43)
at com.bmuschko.gradle.docker.utils.ThreadContextClassLoader$withClasspath.call(Unknown Source)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask.runInDockerClassPath(AbstractDockerRemoteApiTask.groovy:53)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask$runInDockerClassPath.callCurrent(Unknown Source)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask.start(AbstractDockerRemoteApiTask.groovy:47)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 68 more
Caused by: java.lang.reflect.InvocationTargetException
at java_lang_reflect_Method$invoke.call(Unknown Source)
at java_lang_reflect_Method$invoke.call(Unknown Source)
at com.bmuschko.gradle.docker.utils.DockerThreadContextClassLoader$_createPrintStreamProxyCallback_closure8.doCall(DockerThreadContextClassLoader.groovy:354)
at com.sun.proxy.$Proxy373.invoke(Unknown Source)
... 86 more
Caused by: com.github.dockerjava.api.DockerClientException: Could not build image: unauthorized: authentication required
at com.github.dockerjava.core.command.BuildImageResultCallback.getImageId(BuildImageResultCallback.java:71)
at com.github.dockerjava.core.command.BuildImageResultCallback.awaitImageId(BuildImageResultCallback.java:48)
... 90 more
the relevant bit is probably this one:
Caused by: com.github.dockerjava.api.DockerClientException: Could not build image: unauthorized: authentication required
You need to configure the registry credentials.
Yes I did.
docker {
url = 'unix:///var/run/docker.sock'
registryCredentials {
url = dockerRegistryUrl
username = dockerRegistryUser
password = dockerRegistryPass
email = dockerRegistryEmail
}
}
and also executed docker login before running build.
To me, docker-java-3.0.6 fixed this issue. I see that the master branch of gradle-docker-plugin already contains 3.0.6 Is there a new release possible/planned even though this would just contain the version bump of docker-java?
@rafaroca some bits do indeed work but not all. The owner/maintainer of docker-java has been working on proper osx support but is not yet ready.
I can certainly release a new version if it will help with your workload.
@cdancy I just tested my use case again. Some parts are indeed not working. My gradle build starts but has issues. Appreciate your offer but I realize that a new version would not help here.
Had to do this to get it working.
docker run -d -v /var/run/docker.sock:/var/run/docker.sock -p 2375:2375 bobrik/socat TCP4-LISTEN:2375,fork,reuseaddr UNIX-CONNECT:/var/run/docker.sock
With docker-machine
I have the following working:
docker {
url = System.getenv('DOCKER_HOST')
certPath = new File(System.getenv('DOCKER_CERT_PATH'))
}
It seems to me that this should maybe be default behaviour?
@Alxandr that is more for a general use-case and not really relevant to the topic at hand.
Closing issue for now as I use docker on mac on a daily basis and cannot reproduce the OP's ISSUE (at least not with the latest plugin and latest docker-on-mac). Setting docker.url to unix:///var/run/docker.sock
is working as expected.
Getting this.
Tried setting DOCKER_HOST to the docker socket but this gradle task still doesn't work
If i try
I get
? https://forums.docker.com/t/worked-around-docker-http-s-api-no-longer-available-in-beta9/10474/6
https://github.com/docker-java/docker-java/issues/537