Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/java/com/github/dockerjava/client/DockerClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.github.dockerjava.client.command.ListContainersCmd;
import com.github.dockerjava.client.command.ListImagesCmd;
import com.github.dockerjava.client.command.LogContainerCmd;
import com.github.dockerjava.client.command.PingCmd;
import com.github.dockerjava.client.command.PullImageCmd;
import com.github.dockerjava.client.command.PushImageCmd;
import com.github.dockerjava.client.command.RemoveContainerCmd;
Expand Down Expand Up @@ -174,6 +175,10 @@ public AuthCmd authCmd() {
public InfoCmd infoCmd() throws DockerException {
return new InfoCmd().withBaseResource(baseResource);
}

public PingCmd pingCmd() {
return new PingCmd().withBaseResource(baseResource);
}

public VersionCmd versionCmd() throws DockerException {
return new VersionCmd().withBaseResource(baseResource);
Expand Down
29 changes: 29 additions & 0 deletions src/main/java/com/github/dockerjava/client/command/PingCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.github.dockerjava.client.command;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;

/**
* Ping the Docker server
*
*/
public class PingCmd extends AbstrDockerCmd<PingCmd, Integer> {

private static final Logger LOGGER = LoggerFactory.getLogger(PingCmd.class);

protected Integer impl() {
WebResource webResource = baseResource.path("/_ping");

try {
LOGGER.trace("GET: {}", webResource);
ClientResponse resp = webResource.get(ClientResponse.class);
return resp.getStatus();
} catch (UniformInterfaceException exception) {
return exception.getResponse().getStatus();
}
}
}