docker-client-0.1.0: Funflow's internal docker engine client
Safe HaskellNone
LanguageHaskell2010

Docker.API.Client

Synopsis

Documentation

dockerAPIVersion :: String Source #

Docker Engine API version. This value will prefix all docker api url paths.

newtype OS Source #

Alias for the system type returned by System.Info.os

Constructors

OS String 

defaultDockerUnixSocket :: FilePath Source #

Default docker socket path on unix systems

newDefaultDockerManager :: OS -> IO Manager Source #

Creates a new HTTP connection manager for the default docker daemon address on your system.

newUnixDomainSocketManager :: FilePath -> IO Manager Source #

Creates a new http connection manager from a file path to a unix socket

data DockerClientError Source #

This type describes common errors the docker client might encounter

Constructors

ContainerCreationFailedError String

The request to create a new container failed

UnrecognizedJSONResponseError String

The docker engine API responded with something we didn't expect

GetContainerArchiveError String

The docker engine API responded with an error status code when getting a container archive

NonZeroExitCode String

The container exited with a nonzero exit code

GetContainerLogsError String

The docker engine API responded with an error when we attempted to get a container's logs

ImagePullError String

The docker engine API responded with an error when we attempted to pull an image

Instances

Instances details
Show DockerClientError Source # 
Instance details

Defined in Docker.API.Client.Internal.Types

Generic DockerClientError Source # 
Instance details

Defined in Docker.API.Client.Internal.Types

Associated Types

type Rep DockerClientError :: Type -> Type #

type Rep DockerClientError Source # 
Instance details

Defined in Docker.API.Client.Internal.Types

type Rep DockerClientError = D1 ('MetaData "DockerClientError" "Docker.API.Client.Internal.Types" "docker-client-0.1.0-BaMdEBOW2kNI2w9fxdLf37" 'False) ((C1 ('MetaCons "ContainerCreationFailedError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: (C1 ('MetaCons "UnrecognizedJSONResponseError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "GetContainerArchiveError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))) :+: (C1 ('MetaCons "NonZeroExitCode" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: (C1 ('MetaCons "GetContainerLogsError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :+: C1 ('MetaCons "ImagePullError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))))

type ClientErrorMonad a = ExceptT DockerClientError IO a Source #

Wrapper for composing operations which return an Either DockerClientError a

data ContainerSpec Source #

Describes a docker container to be created with runContainer. Use defaultContainerSpec to get a default value.

Constructors

ContainerSpec 

Fields

  • image :: Text

    The image name with an optional tag or digest field (e.g. "python:3.6")

  • cmd :: [Text]

    The container's command. If empty will default to the image default.

  • user :: Text

    Optional user ID to use in the container. If empty will default to the image default.

  • workingDir :: Text

    Optional working directory in the container. If empty will default to the image default.

  • envVars :: [Text]

    Optional list of environment variables of format "FOO=BAR".

  • hostVolumes :: [Text]

    Optional list of host volumes to mount to the container as bind mounts. Must follow the format specied here: https://docs.docker.com/storage/bind-mounts/

Instances

Instances details
Show ContainerSpec Source # 
Instance details

Defined in Docker.API.Client.Internal.Types

Generic ContainerSpec Source # 
Instance details

Defined in Docker.API.Client.Internal.Types

Associated Types

type Rep ContainerSpec :: Type -> Type #

type Rep ContainerSpec Source # 
Instance details

Defined in Docker.API.Client.Internal.Types

type Rep ContainerSpec = D1 ('MetaData "ContainerSpec" "Docker.API.Client.Internal.Types" "docker-client-0.1.0-BaMdEBOW2kNI2w9fxdLf37" 'False) (C1 ('MetaCons "ContainerSpec" 'PrefixI 'True) ((S1 ('MetaSel ('Just "image") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "cmd") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "user") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :*: (S1 ('MetaSel ('Just "workingDir") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "envVars") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text]) :*: S1 ('MetaSel ('Just "hostVolumes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Text])))))

defaultContainerSpec Source #

Arguments

:: Text

The container's Docker Image. May optionally include a tag or digest field (e.g. "python:3.6"). If neither a tag or digest is specified the image will default to the latest tag.

-> ContainerSpec 

Constructs a simple default ContainerSpec for a docker image which uses the image's default values for all other aguments.

runContainer Source #

Arguments

:: Manager

The connection manager for the docker daemon. You can newDefaultDockerManager to get a default connection manager based on your operating system.

-> ContainerSpec 
-> ClientErrorMonad ContainerId 

Similar to the `docker run` command. Runs a container in the background using the input HTTP connection manager, returning immediately. To wait for the container to exit use awaitContainer. Note that this currently always tries to pull the container's image.

saveContainerArchive Source #

Arguments

:: Manager

The connection manager for the docker daemon

-> UserID

The user id to use for output files and directories

-> GroupID

The group id to use for output files and directories

-> FilePath

The path in the container to copy

-> FilePath

The output path at which to write outputs

-> ContainerId 
-> ClientErrorMonad () 

Analagous to the `docker cp` command. Recursively copies contents at the specified path in the container to the provided output path on the host, setting file permissions to the specified user and group id. Note that the container must have been started for this to succeed (i.e. it must have a running or finished state). This method uses conduit to optimize memory usage.

removeContainer Source #

Arguments

:: Manager

The connection manager for the docker daemon

-> Bool

Enable force removal?

-> Bool

Also remove container's volumes?

-> ContainerId 
-> ClientErrorMonad ContainerId 

Remove a container, equivalent to the `docker container rm` command

saveContainerLogs Source #

Arguments

:: Manager

The connection manager for the docker daemon

-> ContainerLogType

Which logs to fetch from the container

-> FilePath

Output file at which to write logs

-> ContainerId 
-> ClientErrorMonad () 

Streams the logs from a docker container into the specified output file path. Logs can include stdout, stderr, or both. Note that if you include both streams, the sorting of the timestamps in the output file may not be perfectly sorted since the stream returned by the docker api is only sorted within each stream type (i.e. stdout and stderr are sorted separately).

pullImage Source #

Arguments

:: Manager

The connection manager for the docker daemon

-> Text

The image of interest. May include an optional tag or digest field. Note that in line with the Docker Engine API, this will pull **ALL** images in a repo if no tag or digest is specified.

-> ClientErrorMonad () 

Pulls an image from a remote registry (similar to a `docker pull` command). This currently only supports public registries (e.g. DockerHub).

awaitContainer Source #

Arguments

:: Manager

The connection manager for the docker daemon. You can newDefaultDockerManager to get a default connection manager based on your operating system.

-> ContainerId

The container id to await

-> ClientErrorMonad () 

Waits on a started container (e.g. via runContainer) until it exits, validating its exit code and returning an DockerClientError if the container exited with an error. This will work for both actively running containers and those which have already exited.

printContainerLogs Source #

Arguments

:: Manager

The connection manager for the docker daemon

-> ContainerLogType

Which logs to fetch from the container

-> ContainerId 
-> ClientErrorMonad () 

Streams the logs from a docker container, printing them to stdout. Logs can include stdout, stderr, or both.