Interface DockerAPI


public interface DockerAPI
Interface to the Docker API.
  • Field Details

    • APPLICATION_VND_DOCKER_RAW_STREAM

      static final String APPLICATION_VND_DOCKER_RAW_STREAM
      The docker output stream format.
      See Also:
    • HEADER_UNUSED_BYTES

      static final int HEADER_UNUSED_BYTES
      The 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

      @POST @Path("/containers/{id}/start") void start(@PathParam("id") String id)
      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 @Path("/containers/{id}") void delete(@PathParam("id") String id)
      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

      static DockerAPI createClient(String url)
      Get a client for the API.
      Parameters:
      url - The URL to connect to.
      Returns:
      A proxy of the API.
    • readLog

      static String readLog(byte[] data) throws IOException
      Read docker log raw format.
      Parameters:
      data - The data returned by getLog(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.