GithubHelp home page GithubHelp logo

docker-java / docker-java Goto Github PK

View Code? Open in Web Editor NEW
2.9K 101.0 1.0K 5.66 MB

Java Docker API Client

License: Apache License 2.0

Shell 0.69% Java 99.06% Dockerfile 0.25%
docker api java client-library docker-java

docker-java's Introduction

docker-java's People

Contributors

albers avatar alexec avatar bsideup avatar carlossg avatar chinanwu avatar denlap007 avatar dependabot[bot] avatar docker-java-maintain avatar dtretyakov avatar eddumelendez avatar fbuecklers avatar fengxx avatar freva avatar gesellix avatar hugares avatar kostyasha avatar kpelykh avatar magnayn avatar marcuslinke avatar mfulgo avatar ndeloof avatar oleg-nenashev avatar patelrit avatar rtimush avatar sabre1041 avatar tejksat avatar vjuranek avatar vuminhkh avatar xfournet avatar yuting-liu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-java's Issues

CommitCmd posts incorrect object

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)

More issues with ports in payloads

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.

[Request] Reduce LoggingFilter level to fine (or lower)

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.

Add wildcard support

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!

Problem with Jersey and other JAXRS providers

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?

Should at least document the Jersey 2.x requirement

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).

Invalid URL when Config has no version

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.)

Add DockerClientConfigBuilder as parameter for getInstance method.

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.

Support Unix Socket Connections

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.

Catch ClientErrorException may do nothing when request is POST mode.

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...

Unnecessary POST body in AttachContainerCmd

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.

Use lowest possible API version for best server compatibility

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.

Expose the possibility to attach a terminal to the started container

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.

Push command should support tag in query parameter

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.

Implements Exec-start and Exec-create

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?

Unrecognized field "Paused"

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.

Problem starting a container

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);

Feature request withEntrypoint

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.

Image not found partial broken

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}

Building image from dockerfile doesn't have name/repository/tag?

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

0.10.1 release date

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

Configured credentials are not used when pushing/pulling an image

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.

Reconsider Jetty dependency?

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.

DNS properties are incorrectly typed as Strings

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.

ExposedPorts and Volumes constructor parameters

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.

Make DockerClient more test-friendly

Attempting to use DockerClient with unit-tested code is a bit of a challenge:

  • You can mock or stub it, but with the new Cmd objects it returns, you have to mock or stub those objects as well (or use deep stubs). This leads to a whole lot of boilerplate and very brittle tests.
  • There's no way to inject mocks for the Cmd objects since it creates new instances of them directly.

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: HTTP 304 Not Modified

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

Boot2Docker and create command throws an exception

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?

DockerCmdExecFactoryImpl could not be instantiated

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 :(

Is pull image asynchronous?

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.

License

Hi guys,

not really a issue but you should edit your LICENSE file in line 190 where the owner and the date is stated.

Remove Guava dependency

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.