A modern Java client for Docker: fluent API, test-friendly, and Kubernetes-ready.
✅ A fluent, strongly typed API.
✅ Support for building images with and without root access.
✅ Easy integration with CI and tests.
✅ First-class support for capturing stdout/stderr and process exit status.
To get started, add this Maven dependency:
<dependency>
<groupId>io.github.cowwoc.anchor4j</groupId>
<artifactId>anchor4j</artifactId>
<version>0.10</version>
</dependency>
import client.io.github.cowwoc.anchor4j.docker.Docker;
import java.io.IOException;
class Example
{
public static void main(String[] args)
throws IOException, InterruptedException
{
Docker docker = Docker.connect();
String imageId = docker.buildImage().
export(Exporter.dockerImage().build()).
build(".");
docker.tagImage(id, "rocket-ship");
docker.pushImage("rocket-ship").push();
}
}
See the API documentation for more details.
If you find this project helpful, please consider sponsoring me. Maintaining quality open-source software takes significant time and effort—especially while balancing family life with young children. Your support helps make this work sustainable.
The anchor4j
API covers a wide range of functionality, and since my time is limited, new features are added
based on user requests. If there's a property or capability you'd like to see added,
please open a new issue.
The modules are dual-licensed:
-
✅ ModernJDK License (free for personal use or small businesses):
- You may use, modify, and redistribute this software for free when:
- It is compiled for and executed on the latest generally available (GA) Java Development Kit (JDK) version at the time of deployment.
- You are an individual or a company with 10 or fewer employees.
- You do not rebrand or white-label the software.
- You are not required to update existing deployments when a newer JDK is released.
- You may use, modify, and redistribute this software for free when:
-
- Required for:
- Compiling, running, or distributing the software for older (non-GA) JDK versions.
- Use by companies with more than 10 employees.
- White-labeling or rebranding the library in any form.
- Required for:
- See Third party licenses for the licenses of the dependencies.