Interface DockerAPI
public interface DockerAPI
Interface to the Docker API.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DockerAPI.WaitCondition
Options for waiting. -
Field Summary
Fields Modifier and Type Field Description static String
APPLICATION_VND_DOCKER_RAW_STREAM
The docker output stream format.static int
HEADER_UNUSED_BYTES
The number of bytes in the log header that are unused. -
Method Summary
Modifier and Type Method Description DockerCreateResponse
create(DockerCreateRequest request)
Create a new Docker container.static DockerAPI
createClient(String url)
Get a client for the API.void
delete(String id)
Delete a Docker container.byte[]
getLog(String id, boolean stdout, boolean stderr)
Get the raw logs of the container.DockerInspectResponse
inspect(String id)
Get the state of a container.static String
readLog(byte[] data)
Read docker log raw format.void
start(String id)
Start a Docker container.void
wait(String id, DockerAPI.WaitCondition condition)
Wait for a Docker container to exit.
-
Field Details
-
APPLICATION_VND_DOCKER_RAW_STREAM
The docker output stream format.- See Also:
- Constant Field Values
-
HEADER_UNUSED_BYTES
static final int HEADER_UNUSED_BYTESThe number of bytes in the log header that are unused.- See Also:
- Constant Field Values
-
-
Method Details
-
create
@Produces("application/json") @Consumes("application/json") @POST @Path("/containers/create") DockerCreateResponse create(DockerCreateRequest request)Create a new Docker container.- Parameters:
request
- The details of the container to create.- Returns:
- The response to the container creation request.
-
start
Start a Docker container.- Parameters:
id
- The identifier of the container.
-
inspect
@GET @Produces("application/json") @Path("/containers/{id}/json") DockerInspectResponse inspect(@PathParam("id") String id)Get the state of a container.- Parameters:
id
- The identifier of the container.- Returns:
- The state description.
-
wait
@POST @Path("/containers/{id}/wait") void wait(@PathParam("id") String id, @QueryParam("condition") DockerAPI.WaitCondition condition)Wait for a Docker container to exit.- Parameters:
id
- The identifier of the container.condition
- What we are waiting for.
-
delete
Delete a Docker container.- Parameters:
id
- The identifier of the container.
-
getLog
@Produces("application/vnd.docker.raw-stream") @GET @Path("/containers/{id}/logs") byte[] getLog(@PathParam("id") String id, @QueryParam("stdout") boolean stdout, @QueryParam("stderr") boolean stderr)Get the raw logs of the container.- Parameters:
id
- The identifier of the container.stdout
- True if STDOUT should be read.stderr
- True if STDERR should be read.- Returns:
- The raw data stream. See
readLog(byte[])
for how this is read.
-
createClient
Get a client for the API.- Parameters:
url
- The URL to connect to.- Returns:
- A proxy of the API.
-
readLog
Read docker log raw format.- Parameters:
data
- The data returned bygetLog(java.lang.String, boolean, boolean)
.- Returns:
- A decoded String containing all data in order received.
- Throws:
IOException
- If an error occurs when reading the log.
-