Skip to content

Commit

Permalink
Container.exitCode() scaffolding
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Dec 13, 2017
1 parent 7ebbc03 commit 4a06ab1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/co/comdor/DockerHost.java
Expand Up @@ -25,6 +25,7 @@
*/
package co.comdor;

import com.spotify.docker.client.messages.ContainerInfo;
import java.io.IOException;
import org.slf4j.Logger;

Expand Down Expand Up @@ -77,4 +78,10 @@ public interface DockerHost {
*/
void remove(final String containerId);

/**
* Inspect a container, get the info about it.
* @param containerId The container's ID.
* @return ContainerInfo.
*/
ContainerInfo inspect(final String containerId);
}
18 changes: 18 additions & 0 deletions src/main/java/co/comdor/RtDockerHost.java
Expand Up @@ -33,6 +33,7 @@
import com.spotify.docker.client.exceptions.DockerException;
import com.spotify.docker.client.messages.ContainerConfig;
import com.spotify.docker.client.messages.ContainerCreation;
import com.spotify.docker.client.messages.ContainerInfo;
import org.slf4j.Logger;

import java.io.IOException;
Expand Down Expand Up @@ -224,5 +225,22 @@ public void kill(final String containerId) {
);
}
}

@Override
public ContainerInfo inspect(final String containerId) {
if(this.client == null) {
throw new IllegalStateException(
"Not connected. Don't forget to get a connected "
+ "instance by calling #connect()"
);
}
try {//.state().exitCode();
return this.client.inspectContainer(containerId);
} catch (final DockerException | InterruptedException ex) {
throw new IllegalStateException(
"Exception when inspecting container with id " + containerId, ex
);
}
}

}

0 comments on commit 4a06ab1

Please sign in to comment.