Java API client for Docker
docker-java / docker-java Goto Github PK
View Code? Open in Web Editor NEWJava Docker API Client
License: Apache License 2.0
Java Docker API Client
License: Apache License 2.0
Java API client for Docker
You should be able to mock the Docker Hub server for the purpose of unit tests. This would make it much easier to work with the code right away if you have no intention of using the library to interact with the hub.
I'm pretty sure that this line should be:
ObjectNode ObjectNode = webResource.accept("application/vnd.docker.raw-stream").post(ObjectNode.class, commitConfig);
(commitConfig
rather than params
)
I'm afraid my pervious pull request was probably the wrong approach. I think the better thing would have been to change the definition of ports in Container
to List<Port>
here https://github.com/docker-java/docker-java/blob/master/src/main/java/com/github/dockerjava/client/model/Container.java#L43
In the other places, it appears that the ports are specific in the original PortMap format.
Here's the summary of places where this is an issue:
Container.ports
is a List<Port>
(see http://docs.docker.com/reference/api/docker_remote_api_v1.12/#list-containers)
ContainerInspectResponse.NetworkSettings.portMapping
is deprecated, but it's a Map<String,String>
(see https://github.com/dotcloud/docker/blob/master/daemon/network_settings.go)
HostConfig.portBindings
is a PortMap
(see http://docs.docker.com/reference/api/docker_remote_api_v1.12/#inspect-a-container)
StartContainerConfig.portBindings
is a PortMap
(see http://docs.docker.com/reference/api/docker_remote_api_v1.12/#start-a-container)
I'll work on a pull request to fix these.
It is relatively common practice to log the info level to disk as it gives a decent idea as to what is occurring without filling the disk. docker-java logs every json request at the info level. These log messages are large and frequent, I have hundreds of megabytes of json filling my logs!
I propose logging the requests at fine or finest.
I'm pretty sure that Config
should be a public class and that Config#createConfig()
should also be public.
If they're not, the public DockerClient(Config)
constructor can't easily be called.
Hi!
I have a Dockerfile that issues the following command:
ADD ./build/libs/*.war /opt/tomcat/webapps/
The Dockerfile works correctly if I use the docker cli, but fails if docker-java is used to launch the docker build image.
I have tested it with the Gradle Docker plugin (https://github.com/bmuschko/gradle-docker-plugin), which
uses docker-java lib.
Here is the relevant part of the stack trace:
Caused by: com.github.dockerjava.api.DockerClientException: Source file /Users/carlos/Code/sla/berri/spring/boot/build/libs/*.war doesn't exist
at com.github.dockerjava.core.command.BuildImageCmdImpl.buildDockerFolderTar(BuildImageCmdImpl.java:241)
at com.github.dockerjava.core.command.BuildImageCmdImpl.<init>(BuildImageCmdImpl.java:51)
at com.github.dockerjava.core.DockerClientImpl.buildImageCmd(DockerClientImpl.java:248)
at com.github.dockerjava.api.DockerClient$buildImageCmd.call(Unknown Source)
Thanks very much!
Hi, currently we are using docker-java in Arquillian Cube so we can write integration tests using Arquillian and Docker. We have several users that have had one problem which is recurrent. they are using RESTEasy as jaxrs provider, and arquillian cube for writing their tests. The problem is that when they run the test there is an exception from docker-client that it doesn't know which provider use and of course the test cannot be executed.
I think that for a generic library like docker-client should avoid using these kind of spi. Keep in mind that the same problem may occurs if user uses another version of jersey. So in fact what is happening here is that a library is fixing the version of the product.
I think that docker-client should not depend on jersey nor any jaxrs implementation and use native HttpUrlConnection to interact with docker server and for example and use an small light none dependent library like json.jar to parse json.
WDYT?
For a variety of reasons the DropWizard framework (which gets fairly wide use) is still on Jersey 1.18. The fact that this library has moved on to Jersey 2.x means that it can't be used as part of a DW application (which unfortunately is my use case).
I'll be forking this to take it back to 1.18 for those of us who cannot switch. In the meantime you probably want to document this requirement. You may also want to consider whether you really need to be using Jersey 2.x (since I think you can use 1.18 client code in a 2.x application, but you can't go the other way due to the use of methods that don't exist in 1.18).
If you construct a DockerClient
using a Config
object that has a null version
property, you'll get a baseResource
of something like http://localhost:1234/vnull
.
Perhaps we should add some checking to the build()
method of the DockerClientConfigBuilder
. You can run into related badness if the URI
is null. (And just for good measure, we should make the readTimeout
an int
rather than an Integer
.)
when pulling 0.9.1 via maven in eclipse the jar doesn´t contains new classes, as well 0.9.1 test as main are obsolet
Using current approach for configuring Docker you can end up to an expression like:
DockerClient dockerClient = DockerClientBuilder.getInstance(configBuilder.build()).build();
To avoid this "double call to build method together", you can add a new getInstance method which takes DockerClientConfigBuilder as parameter.
Hi,
is there a way to specify a parameter like --net=none (or --cap-add=NET_ADMIN) through the method createContainerCmd of the class DockerClient?
Thanks,
C.
This is a feature request:
It would be nice if the client also supported a socket connection (defaulting to /var/run/docker.sock
). That way, you wouldn't have to make any changes to the docker configuration, and it would just work out of the box.
The more configuration steps we can eliminate when using this in a CI build environment, the better.
In class AbstrDockerCmd. Method exec() want catch ClientErrorException to handle http status other than 200(Some error happend). But this may only work when do GET method.
For example, DockerClient.inspectContainerCmd(containerId) method use HTTP_GET method and work well. But if we call DockerClient.stopContainerCmd(containerId) method and try catch NotFoundException or/and NotModifiedException to get stop operation result. This issues will cause we always got nothing even though target container not exist.
Sorry for my poor English...
There's no test for it right now... I don't think we need to send the params as the POST body in the AttachContainerCmd
.
I haven't checked all of the other commands for the same issue.
Using the latest API version number (right now, 1.14) means that the library can't talk to older servers. I think in most cases the functionality in docker-java is compliant with much older versions. I'd argue that this is best done endpoint-by-endpoint, rather than as a global version, so that when the code is written, the minimum compliant API is coded into the implementation for that command.
It's possible I'm wrong about this, and global latest version is best for the most people, but this bites me from time to time because our server is on CentOS 6 (not my idea) and the latest docker-io on EPEL commonly lags the current release by weeks.
I am working on a framework to coordinate integration tests for a number of containers that are configured as docker images. For that I am using docker-java 0.9.1 and have found that (some) of my container die immediately after they have been started because there is no terminal attached to them.
To overcome this I have patched docker-java 0.9.2-SNAPSHOT to expose the withTTY method for container creation. I will create a pull request for this issue.
how to add some options when creating a container ?
When pushing image to docker registry, the REST API is:
POST /images/(name)/push
Query Parameters:
tag – the tag to associate with the image on the registry, optional
Right now tag is not supported in push command.
You can create and configure DockerClient by using an static method and passing a properties file. This is really cool but I think that methods like createContainerCmd, startContainerCmd, and so on should implement as well.
I have downloaded latest version of docker-java and I have not found that exec-start and exec-create commands are available. As you said in the library description it offers a partial implementation of the full set of commands. Do you have any plan to implement them?
I think this issue is probably "please support Docker 1.0".
I tried to use https://wiki.jenkins-ci.org/display/JENKINS/Docker+build+step+plugin which uses this library, against docker 1.0, and got:
FATAL: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Paused" (class com.kpelykh.docker.client.model.ContainerInspectResponse$ContainerState), not marked as ignorable (6 known properties: "StartedAt", "FinishedAt", "Pid", "ExitCode", "Running", "Ghost"])
at [Source: com.sun.jersey.client.apache4.ApacheHttpClient4Handler$HttpClientResponseInputStream@361b9d4e; line: 1, column: 974] (through reference chain: com.kpelykh.docker.client.model.ContainerInspectResponse["State"]->com.kpelykh.docker.client.model.ContainerState["Paused"])
com.sun.jersey.api.client.ClientHandlerException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Paused" (class com.kpelykh.docker.client.model.ContainerInspectResponse$ContainerState), not marked as ignorable (6 known properties: "StartedAt", "FinishedAt", "Pid", "ExitCode", "Running", "Ghost"])
at [Source: com.sun.jersey.client.apache4.ApacheHttpClient4Handler$HttpClientResponseInputStream@361b9d4e; line: 1, column: 974] (through reference chain: com.kpelykh.docker.client.model.ContainerInspectResponse["State"]->com.kpelykh.docker.client.model.ContainerState["Paused"])
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:644)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:586)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:686)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509)
at com.kpelykh.docker.client.DockerClient.inspectContainer(DockerClient.java:554)
at org.jenkinsci.plugins.dockerbuildstep.cmd.CreateContainerCommand.execute(CreateContainerCommand.java:74)
at org.jenkinsci.plugins.dockerbuildstep.DockerBuilder.perform(DockerBuilder.java:65)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:745)
at hudson.model.Build$BuildExecution.build(Build.java:198)
at hudson.model.Build$BuildExecution.doRun(Build.java:159)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:518)
at hudson.model.Run.execute(Run.java:1706)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "Paused" (class com.kpelykh.docker.client.model.ContainerInspectResponse$ContainerState), not marked as ignorable (6 known properties: "StartedAt", "FinishedAt", "Pid", "ExitCode", "Running", "Ghost"])
at [Source: com.sun.jersey.client.apache4.ApacheHttpClient4Handler$HttpClientResponseInputStream@361b9d4e; line: 1, column: 974] (through reference chain: com.kpelykh.docker.client.model.ContainerInspectResponse["State"]->com.kpelykh.docker.client.model.ContainerState["Paused"])
at com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
at com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:671)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:773)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1297)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1275)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:215)
at com.fasterxml.jackson.databind.deser.impl.InnerClassProperty.deserializeAndSet(InnerClassProperty.java:102)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:242)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:118)
at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1233)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:677)
at com.fasterxml.jackson.jaxrs.base.ProviderBase.readFrom(ProviderBase.java:777)
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:634)
... 16 more
I don't see "Paused" in https://github.com/docker-java/docker-java/blob/master/src/main/java/com/kpelykh/docker/client/model/ContainerInspectResponse.java#L250. It was added in moby/moby@b054569
It also looks like "Ghost" was removed.
The existing attach operation doesn't allow interaction with the container through stdin/out/err. This should be implemented.
Hi,
Started working with your project, trying to start a rabbitmq container (basic one from https://github.com/mikaelhg/docker-rabbitmq)
When Calling
dockerClient.startContainerCmd(container.getId())
.withPortBindings(getPortBindings())
.exec();
I get, for some reason this (below), can anyone help?
Is it possible that this is failing due to jersey conflicts? I'm working inside a DropWizard 0.6.2 project
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.resolveTemplate(Ljava/lang/String;Ljava/lang/Object;Z)Ljavax/ws/rs/core/UriBuilder;
at org.glassfish.jersey.client.JerseyWebTarget.resolveTemplate(JerseyWebTarget.java:246)
at org.glassfish.jersey.client.JerseyWebTarget.resolveTemplate(JerseyWebTarget.java:237)
at org.glassfish.jersey.client.JerseyWebTarget.resolveTemplate(JerseyWebTarget.java:59)
at com.github.dockerjava.jaxrs.StartContainerCmdExec.exec(StartContainerCmdExec.java:23)
at com.github.dockerjava.jaxrs.StartContainerCmdExec.exec(StartContainerCmdExec.java:13)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:42)
at com.github.dockerjava.core.command.StartContainerCmdImpl.exec(StartContainerCmdImpl.java:255)
at integration.DockerClientRule.before(DockerClientRule.java:90)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
Apparently in JerseyWebTarget ln 246 - "this" is null
return new JerseyWebTarget(getUriBuilder().resolveTemplate(name, value, encodeSlashInPath), this);
Just noticed that a "withEntrypoint" method is missing from the createContainerCmd. This makes it currently impossible to override the entrypoint defined in the image.
I'll take a look at it but maybe somebody else is quicker then I am.
Hi guys,
just noticed the java-sources (and doc) are missing from the SNAPSHOT builds. Not sure if it's travis-ci or custom cmd after deploy related. Could you have a look at it?
greets
DockerClient creates a http client with a connection pool. DockerClient should probably implement Closeable or preferrably AutoCloseable and have that method destroy the client.
If I try to pull an image that dosn't exist, I should get an InternalServerErrorException.
Example:
POST http://DOCKERHOSTWITH1.15API:2375/images/create?fromImage=ha-CK-Mann/noneexist1
will throw an InternalServerErrorException. That's the expected behaviour.
But there seem to be some errors in the implementation that render it broken for some edge-cases. E.g. take this example:
POST http://DOCKERHOSTWITH1.15API:2375/images/create?fromImage=hackmann/emptyrrrddd
will NOT throw an internalServerErrorException. However, the docker API does respond with some JSON indicating that the image dosn't exist:
{errorDetail={message=Error: image hackmann/emptyrrrddd not found}, error=Error: image hackmann/emptyrrrddd not found}
Edit: Ok, I've completely missed the "withtag" method ;-( sry...
Hi,
I've tried the "build image from dockerfile" sample from the wiki.
Building an image from a dockerfile works, but it doesn't have a name and tag, it's just listed as .
Is this not supported or am I completely missing something?
Or is the way it's done here by subsequently getting the image by Id and then tagging it manually?
BR
Daniel
Hi guys,
I want to move my plugin back onto your version. Please can you tell me if there is any release date for 0.10.0 lined up?
Thank you,
Alex
This is currently missing. In looking at the implementation of the docker client it seems that this is part of the host configuration (comes right after the dns list itself).
I am looking for an example or test case that uses the Docker daemon but then pushes the image to the repository in the DockerHub registry instead of the local repository (or both). My DockerClientConfig
looks as such:
DockerClientConfig config = DockerClientConfig.createDefaultConfigBuilder()
.withUri("https://my-docker-host.tld:2376")
.withUsername("dockeruser")
.withPassword("ilovedocker")
.withEmail("[email protected]")
.withServerAddress("https://index.docker.io/v1/")
.build();
How is the serverAddress
taken into account? I'd expect that it is used to define the target registry. Could you shed some light on this use case?
Do I need to define a tag that uses index.docker.io as part of the image tag as described on the Docker API documentation page? If I try that, a com.github.dockerjava.core.InvalidRepositoryNameException
is thrown. Shouldn't that be possible?
Let me know if I am missing something completely here.
I'm a bit sorry for bringing this up, but would it be possible to reconsider the jetty-client dependency (jersey-jetty-connector)?
It seems like the Jetty guys has moved a lot of classes around during their 9.0, 9.1 and 9.2 releases and having a Jetty dependency to any of these versions makes it a *** to use in an application deployed on Jetty.
Hi guys, I'm getting a very strange issue working with a gradle docker plugin and artifactories gradle plugin. Here's the error:
Caused by: java.io.IOException: This archives contains unclosed entries.
I've created a couple of issues on their projects here and here. Wondered if you have any thoughts?
Hi,
the documentation states that the latest SNAPSHOT automated build is published to https://oss.sonatype.org/content/groups/public/com/github/docker-java/docker-java/ but I'm unable to find the latest 0.10.4-SNAPSHOT there.
DNS properties are provided as a String throughout when they are actually represented as an array as specified by the Docker Remote API. Any time DNS is provided on a per container basis, there are Jersey exceptions when trying to map a non-null value from the Docker API.
I was wondering if you'd be open to either storing ExportedPort and Volume as java.util.List
instead of an array in their corresponding wrapper classed ExportPorts and Volumes. Alternatively, I also be OK with having another constructor that takes a List
like this:
public ExposedPorts(ExposedPort... exposedPorts) {
this.exposedPorts = exposedPorts;
}
public ExposedPorts(List<ExposedPort> exposedPorts) {
this.exposedPorts = exposedPorts.toArray(new ExposedPort[exposedPorts.size()]);
}
A List
is simply easier to handle than an array. Also invoking their constructors via reflection (my use case) is easier for a List
than it is for varargs. Another argument for a List
is that you already have a List
in the deserialize
method which you then turn into an array.
Getting a list of containers doesn't seem to parse the ports results correctly.
This tells docker to reuse the existing host config and is what the variant used by the docker cli to implement docker start
. AFAICT this isn't possible to match with the current API.
Currently, you cannot bind "/home/andrewguenther/code/app" to an alternate path within the container. This is important and should be added and documented.
Need to configure Jersey to use https, with client certificate authentication and (optionally?) no server certificate check.
Attempting to use DockerClient
with unit-tested code is a bit of a challenge:
What I propose (and feel free to suggest something else) is a CommandFactory
interface that is passed into DockerClient
at construction, which it then uses to create the commands rather than directly calling new SomeCmd()
. A provided default implementation of the factory would basically do just what DockerClient
does now. This would maintain backwards compatibility with the current API and provide a better means of injecting mocks (or spies) for specific commands.
An API-breaking change would be to move the Command creation responsibility out of DockerClient
entirely and into the CommandFactory
. Then, DockerClient
's single responsibility would be to set the baseResource
and authConfig
on commands and execute them (essentially, the execute
method). This would also suggest that the exec method on commands should not be exposed.
Thoughts?
FATAL: com.github.dockerjava.api.NotModifiedException
java.lang.RuntimeException: com.github.dockerjava.api.NotModifiedException
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderControl.perform(DockerBuilderControl.java:61)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:770)
at hudson.model.Build$BuildExecution.build(Build.java:199)
at hudson.model.Build$BuildExecution.doRun(Build.java:160)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
at hudson.model.Run.execute(Run.java:1759)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Caused by: com.github.dockerjava.api.NotModifiedException
at com.github.dockerjava.jaxrs.util.ResponseStatusExceptionFilter.filter(ResponseStatusExceptionFilter.java:41)
at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:134)
at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:123)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:251)
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 com.github.dockerjava.jaxrs.StartContainerCmdExec.execute(StartContainerCmdExec.java:27)
at com.github.dockerjava.jaxrs.StartContainerCmdExec.execute(StartContainerCmdExec.java:13)
at com.github.dockerjava.jaxrs.AbstrDockerCmdExec.exec(AbstrDockerCmdExec.java:47)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:26)
at com.github.dockerjava.core.command.StartContainerCmdImpl.exec(StartContainerCmdImpl.java:281)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderControlOptionProvisionAndStart.execute(DockerBuilderControlOptionProvisionAndStart.java:36)
at com.nirima.jenkins.plugins.docker.builder.DockerBuilderControl.perform(DockerBuilderControl.java:59)
... 9 more
NotModifiedException should be catch-ignored for actions start() and stop()....that's the correct way to handle it
Can I join? I'd like to get my plugin back onto this version!
Hi I don't know if you have tested the library using boot2docker, but we have tried to use and an exception is thrown.
The exception is something like:
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
Caused by: javax.ws.rs.ProcessingException: java.net.SocketException: Unexpected end of file from server
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$2.call(JerseyInvocation.java:683)
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)
Maybe it is a boot2docker configuration problem, but we have tried the same code with a linux docker and runs perfectly and also we have tried using curl
directly to boot2docker and it worked as well.
Any idea?
I'm trying to work with docker-java from my app but I'm having some major issue with classloaders.
When I run the code:
DockerClient dockerClient = DockerClientBuilder.getInstance("http://" + mgmtAddress + ":" + DOCKER_DEFAULT_PORT).build();
I get the following exception the first time I invoke DockerClientBuilder.getInstance(config).build() :
java.util.ServiceConfigurationError: com.github.dockerjava.api.command.DockerCmdExecFactory: Provider com.github.dockerjava.jaxrs.DockerCmdExecFactoryImpl could not be instantiated: java.lang.NoClassDefFoundError: javax/ws/rs/core/Configuration
at java.util.ServiceLoader.fail(ServiceLoader.java:224)
at java.util.ServiceLoader.access$100(ServiceLoader.java:181)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:377)
at java.util.ServiceLoader$1.next(ServiceLoader.java:445)
at com.github.dockerjava.core.DockerClientBuilder.getDefaultDockerCmdExecFactory(DockerClientBuilder.java:43)
at com.github.dockerjava.core.DockerClientBuilder.build(DockerClientBuilder.java:57)
at com.embrane.mgmt.server.mediation.containers.docker.DockerConnection.initializeConnection(DockerConnection.java:68)
at com.embrane.mgmt.server.mediation.containers.docker.DockerConnection.(DockerConnection.java:45)
at com.embrane.mgmt.server.mediation.containers.docker.DockerTopologyTaskImpl.identify(DockerTopologyTaskImpl.java:58)
at com.embrane.mgmt.server.mediation.impl.TopologyTaskImpl.work(TopologyTaskImpl.java:88)
at com.embrane.mgmt.server.core.impl.ReadOnlyTaskImpl.run(ReadOnlyTaskImpl.java:33)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: javax/ws/rs/core/Configuration
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
at java.lang.Class.getConstructor0(Class.java:2803)
at java.lang.Class.newInstance(Class.java:345)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)
... 11 more
Caused by: java.lang.ClassNotFoundException: javax.ws.rs.core.Configuration
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1702)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547)
... 16 more
And the following error message after the first time :
Fatal: Can't find any implementation of 'com.github.dockerjava.api.command.DockerCmdExecFactory' in the current classpath. when attempting to connect to 10.10.35.208
Do you know how can I solve this issue?
I'm pretty desperate :(
Currently I am implementing a self pulling image in case of the container cannot be started because it cannot be found:
try {
return createContainerCmd.exec();
}catch(NotFoundException e) {
this.dockerClient.pullImageCmd(imageName).exec();
return createContainerCmd.exec();
}
Note that what I am doing is trying to create the container and if throws an exception I try to do the pull.
The problem is that if I run this code, pullimage is executed and when create container is executed again, the Not found image exception is thrown again. But then if I reexecute the code without touching anything in docker server (removing images) the first createContainer command is executed correctly. So it seems that pull image is in somehow way asynchronous.
Have you found this problem too?
Thank you so much for your help.
Hi guys,
not really a issue but you should edit your LICENSE file in line 190 where the owner and the date is stated.
Hi I have downloaded Docker-Java code and I have commented Guava dependency and I have seen that it is only used for two reasons, to generate a toString, for escaping url path. IMHO adding a dependency of 2MB for only these three features it seems a bit big. Maybe removing this big dependency and add a self implementation of both methods would fit better the project. First because of download artifects you require to run it, and second and most important because you are going to avoid conflicts with developers, for example if one project needs an old version of guava and cannot run with the one provided by docker-java or for example because company have a policy to not use guava (which I know some companies who have it).
I can help on this but without removing jersey-guava because it is a dependency that comes from jersey-client.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.