Skip to content

Entry point: Docker interface

Mihai edited this page Apr 19, 2020 · 6 revisions

Docker Interface

The library has only one Entry Point: the Docker interface. This interface gives you further access to all APIs of Docker, as well as miscellaneous API endpoints such as ping.

There are two classes implementing the Docker interface, which you can instantiate (these are the only public classes in the whole library!):

Class UnixDocker:

UnixDocker - use this if you are on Linux (Ubuntu, MacOS etc) and want to access the local Docker Engine (you connect to it via a UNIX Socket which you pass in as a File):

final Docker docker = new UnixDocker(
    new File("/var/run/docker.sock")     //this is the default path to Docker's unix socket
);

Class TcpDocker:

TcpDocker - use this if you want to connect to a remote Docker Engine, by passing a URI (we will append a default version of the API after your URI, or you can also specify a version via one of the constructors):

final Docker docker = new TcpDocker(URI.create("https://my.dockerengine.io"));

You can also use TcpDocker to communicate with the localhost Docker Engine, as long as it is configured to work with TCP instead of Unix socket (i.e. on Windows).

Multiple constructors

These two classes have a number of constructors which allow you to specify the API version, or pass in your own Apache HttpClient (we advise you do that only if you really know what you're doing!) etc.