Skip to content

Latest commit

 

History

History
76 lines (54 loc) · 2.49 KB

File metadata and controls

76 lines (54 loc) · 2.49 KB

Overview

Official java docker client is a bit creepy when talking about working with dtos and asynchronous. This lib was made to hide boilerplate when synchronizing container states and converting client dto classes.

Build status

What's there in this bundle?

  • Docker client

Wrapper for official docker client. Allows passing dto with null fields (official client for some reason has assertions in field setters, checking against null values). Also hides most of common request creation code.

    NDockerClient client = new NDockerClient(dockerClient);
    client.startContainer("id");
    
    // vanilla client
    DockerClient client = ...
    client.startContainerCmd(containerId).exec();
  • Docker container

All container commands require passing container id, so it could be encapsulated in another wrapper.

    DockerContainer service1 = new DockerContainer(client, "id");
    DockerContainer service2 = new DockerContainer(client, "id2");
    
    service1.start();
    service2.start();
    
    service2.stop();
    service2.printLogs();
    
    // vanilla client
    DockerClient client = ...
    String service1Id = ...
    String service2Id = ...
        
    client.startContainerCmd(service1Id).exec();
    client.startContainerCmd(service2Id).exec();
    
    client.stopContainerCmd(service2Id).exec();
    client.logContainerCmd(service2Id)
                    .withStdOut()
                    .withStdErr()
                    .exec(new DockerLogger(logConsumer))
                    .awaitCompletion();

License

WTFPL