Skip to content

cowwoc/docker

Repository files navigation

Maven Central build-status

logo Docker Java Client

API Changelog

A Java client for Docker.

To get started, add this Maven dependency:

<dependency>
  <groupId>com.github.cowwoc.docker</groupId>
  <artifactId>docker</artifactId>
  <version>0.9</version>
</dependency>

Example

import com.github.cowwoc.docker.client.DockerClient;
import com.github.cowwoc.docker.exception.ImageNotFoundException;
import com.github.cowwoc.docker.resource.Image;

import java.io.IOException;
import java.nio.file.Path;
import java.util.concurrent.TimeoutException;

class Example
{
  public static void main(String[] args)
    throws IOException, TimeoutException, InterruptedException
  {
    try (DockerClient client = DockerClient.usingUnixSocket(Path.of("/var/run/docker.sock")))
    {
      Image image = Image.builder(client).platform("linux/amd64").build();
      Image image2 = Image.getById(client, image.getId());
      assert (image.equals(image2));

      image.tag("rocket-ship", "local-tag");
      image.pusher(client, "rocket-ship", "remote-tag").
        credentials("username", "Pa33word").
        push();
    }
  }
}

Getting Started

See the API documentation for more details.

Licenses

About

A Java client for Docker

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published