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>
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();
}
}
}
See the API documentation for more details.
- This library is licensed under the Apache License, Version 2.0
- See Third party licenses for the licenses of the dependencies