Invoke Docker Remote API using Java

I’m able to query a Docker host using Remote API as:

curl https://<IP>:2376/images/json --cert cert.p12 --pass mypass --key key.pem --cacert ca.pem

Can anybody help on how to transform this curl REST invocation to any Java library code?

  • Docker Remote API & Binds
  • Requirement to accept network packets in container from host or outside? (docker port forwarding)
  • docker daemon restarting containers when not required to
  • Launching jobs with large docker images in mesos via aurora can be slow
  • Concurrent access to docker.sock on k8s
  • Error when running retrain.py during retraining for image classifier based on tensorflow for poets
  • Looked at Jersey and HttpClient libraries but seems like they require extensive setup.

  • Docker Container Library Duplication
  • can i create instances in Openstack using vagrant or docker?
  • GAE Managed VMs - can't deploy if your project name is too long
  • Docker doesn't install correct on Mac
  • gitlab CI build runs on my local docker container
  • Unable to use docker due to ZScaler and certificate issues
  • One Solution collect form web for “Invoke Docker Remote API using Java”

    Check if the docker-java project can help here.

    From one of the test classes:

        Volume volume1 = new Volume("/opt/webapp1");
    
        Volume volume2 = new Volume("/opt/webapp2");
    
        CreateContainerResponse container = dockerClient.createContainerCmd("busybox").withVolumes(volume1, volume2)
                .withCmd("true").withBinds(new Bind("/src/webapp1", volume1, ro), new Bind("/src/webapp2", volume2))
                .exec();
    

    The Wiki mentions certificates:

    DockerClient dockerClient = DockerClientBuilder.getInstance("http://localhost:2375").build();
    
    // Or: Intialize docker client (advanced)
    
    DockerClientConfig config = DockerClientConfig.createDefaultConfigBuilder()
      .withUri("https://docker.somewhere.tld:2376")
      .withDockerCertPath("/home/user/.docker")
      .withUsername(registryUser)
      .withPassword(registryPass)
      .withEmail(registryMail)
      .withServerAddress(registryUrl)
      .build();
    

    As mentioned in your issue 483, you either:

    • need to use maven and take advantage of the pom.xml dependencies,
    • or use a mvn dependency:list -DincludeScope=runtime to get the list of all runtime dependencies.
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.