docker-0.5.1.1: An API client for docker written in Haskell

Safe HaskellNone
LanguageHaskell2010

Docker.Client.Api

Contents

Synopsis

Containers

listContainers :: forall m. (MonadIO m, MonadMask m) => ListOpts -> DockerT m (Either DockerError [Container]) Source #

Lists all running docker containers. Pass in defaultListOpts {all = True} to get a list of stopped containers as well.

createContainer :: forall m. (MonadIO m, MonadMask m) => CreateOpts -> Maybe ContainerName -> DockerT m (Either DockerError ContainerID) Source #

Creates a docker container but does not start it. See CreateOpts for a list of options and you can use defaultCreateOpts for some sane defaults.

startContainer :: forall m. (MonadIO m, MonadMask m) => StartOpts -> ContainerID -> DockerT m (Either DockerError ()) Source #

Start a container from a given ContainerID that we get from createContainer. See StartOpts for a list of configuration options for starting a container. Use defaultStartOpts for sane defaults.

stopContainer :: forall m. (MonadIO m, MonadMask m) => Timeout -> ContainerID -> DockerT m (Either DockerError ()) Source #

Attempts to stop a container with the given ContainerID gracefully (SIGTERM). The docker daemon will wait for the given Timeout and then send a SIGKILL killing the container.

waitContainer :: forall m. (MonadIO m, MonadMask m) => ContainerID -> DockerT m (Either DockerError ExitCode) Source #

Blocks until a container with the given ContainerID stops, then returns the exit code

killContainer :: forall m. (MonadIO m, MonadMask m) => Signal -> ContainerID -> DockerT m (Either DockerError ()) Source #

Sends a Signal to the container with the given ContainerID. Same as stopContainer but you choose the signal directly.

restartContainer :: forall m. (MonadIO m, MonadMask m) => Timeout -> ContainerID -> DockerT m (Either DockerError ()) Source #

Restarts a container with the given ContainerID.

pauseContainer :: forall m. (MonadIO m, MonadMask m) => ContainerID -> DockerT m (Either DockerError ()) Source #

Pauses a container with the given ContainerID.

unpauseContainer :: forall m. (MonadIO m, MonadMask m) => ContainerID -> DockerT m (Either DockerError ()) Source #

Unpauses a container with the given ContainerID.

deleteContainer :: forall m. (MonadIO m, MonadMask m) => DeleteOpts -> ContainerID -> DockerT m (Either DockerError ()) Source #

Deletes a container with the given ContainerID. See DeleteOpts for options and use defaultDeleteOpts for sane defaults.

getContainerLogs :: forall m. (MonadIO m, MonadMask m) => LogOpts -> ContainerID -> DockerT m (Either DockerError ByteString) Source #

Get's container's logs for a given ContainerID. This will only work with the JsonFile LogDriverType as the other driver types disable this endpoint and it will return a DockerError.

See LogOpts for options that you can pass and defaultLogOpts for sane defaults.

NOTE: his function will fetch the entire log that the container produced in the json-file on disk. Depending on the logging setup of the process in your container this can be a significant amount which might block your application...so use with caution.

If you want to stream the logs from the container continuosly then use getContainerLogsStream

NOTE: It's recommended to use one of the other LogDriverTypes available (like syslog) for creating your containers.

getContainerLogsStream :: forall m b. (MonadIO m, MonadMask m) => LogOpts -> ContainerID -> Sink ByteString m b -> DockerT m (Either DockerError b) Source #

Continuously gets the container's logs as a stream. Uses conduit.

Example:

>>> import Docker.Client
>>> import Data.Maybe
>>> import Conduit
>>> h <- defaultHttpHanlder
>>> let cid = fromJust $ toContainerID "fee86e1d522b"
>>> runDockerT (defaultClientOpts, h) $ getContainerLogsStream defaultLogOpts cid stdoutC

Images

listImages :: forall m. (MonadIO m, MonadMask m) => ListOpts -> DockerT m (Either DockerError [Image]) Source #

Lists all docker images.

buildImageFromDockerfile :: forall m. (MonadIO m, MonadMask m) => BuildOpts -> FilePath -> DockerT m (Either DockerError ()) Source #

Build an Image from a Dockerfile

TODO: Add X-Registry-Config

TODO: Add support for remote URLs to a Dockerfile

TODO: Clean up temp tar.gz file after the image is built

pullImage :: forall m b. (MonadIO m, MonadMask m) => Text -> Tag -> Sink ByteString m b -> DockerT m (Either DockerError b) Source #

Pulls an image from Docker Hub (by default).

TODO: Add support for X-Registry-Auth and pulling from private docker registries.

TODO: Implement importImage function that uses he same CreateImageEndpoint but rather than pulling from docker hub it imports the image from a tarball or a URL.

Other

getDockerVersion :: forall m. (MonadIO m, MonadMask m) => DockerT m (Either DockerError DockerVersion) Source #

Gets the version of the docker engine remote API.