Interface DockerAPI
public interface DockerAPI
Interface to the Docker API.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The docker output stream format.static final int
The number of bytes in the log header that are unused. -
Method Summary
Modifier and TypeMethodDescriptioncreate
(DockerCreateRequest request) Create a new Docker container.static DockerAPI
createClient
(String url) Get a client for the API.void
Delete a Docker container.byte[]
Get the raw logs of the container.Get the state of a container.static String
readLog
(byte[] data) Read docker log raw format.void
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:
-
HEADER_UNUSED_BYTES
static final int HEADER_UNUSED_BYTESThe number of bytes in the log header that are unused.- See Also:
-
-
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.
-