stack-1.4.0: The Haskell Tool Stack

Safe Haskell | None
Language | Haskell2010

Stack.Docker

Description

Run commands in Docker containers

Synopsis

- cleanup :: (StackM env m, HasConfig env) => CleanupOpts -> m ()
- data CleanupOpts = CleanupOpts {
  - dcAction :: !CleanupAction
  - dcRemoveKnownImagesLastUsedDaysAgo :: !(Maybe Integer)
  - dcRemoveUnknownImagesCreatedDaysAgo :: !(Maybe Integer)
  - dcRemoveDanglingImagesCreatedDaysAgo :: !(Maybe Integer)
  - dcRemoveStoppedContainersCreatedDaysAgo :: !(Maybe Integer)
  - dcRemoveRunningContainersCreatedDaysAgo :: !(Maybe Integer)
  }
- data CleanupAction
  - = CleanupInteractive
  - | CleanupImmediate
  - | CleanupDryRun
- dockerCleanupCmdName :: String
- dockerCmdName :: String
- dockerHelpOptName :: String
- dockerPullCmdName :: String
- entrypoint :: (MonadIO m, MonadBaseControl IO m, MonadCatch m, MonadLogger m) => Config -> DockerEntrypoint -> m ()
- preventInContainer :: (MonadIO m, MonadThrow m) => m () -> m ()
- pull :: (StackM env m, HasConfig env) => m ()
- reexecWithOptionalContainer :: (StackM env m, HasConfig env) => Maybe (Path Abs Dir) -> Maybe (m ()) -> IO () -> Maybe (m ()) -> Maybe (m ()) -> m ()
- reset :: (MonadIO m, MonadReader env m, HasConfig env) => Maybe (Path Abs Dir) -> Bool -> m ()
- reExecArgName :: String
- data StackDockerException
  - = DockerMustBeEnabledException
  - | OnlyOnHostException
  - | InspectFailedException String
  - | NotPulledException String
  - | InvalidCleanupCommandException String
  - | InvalidImagesOutputException String
  - | InvalidPSOutputException String
  - | InvalidInspectOutputException String
  - | PullFailedException String
  - | DockerTooOldException Version Version
  - | DockerVersionProhibitedException [Version] Version
  - | BadDockerVersionException VersionRange Version
  - | InvalidVersionOutputException
  - | HostStackTooOldException Version (Maybe Version)
  - | ContainerStackTooOldException Version Version
  - | CannotDetermineProjectRootException
  - | DockerNotInstalledException
  - | UnsupportedStackExeHostPlatformException
  - | DockerStackExeParseException String

# Documentation

cleanup :: (StackM env m, HasConfig env) => CleanupOpts -> m () #

Clean-up old docker images and containers.

data CleanupOpts #

Options for `cleanup`.

Constructors

CleanupOpts |
Fields dcAction :: !CleanupAction dcRemoveKnownImagesLastUsedDaysAgo :: !(Maybe Integer) dcRemoveUnknownImagesCreatedDaysAgo :: !(Maybe Integer) dcRemoveDanglingImagesCreatedDaysAgo :: !(Maybe Integer) dcRemoveStoppedContainersCreatedDaysAgo :: !(Maybe Integer) dcRemoveRunningContainersCreatedDaysAgo :: !(Maybe Integer)

Instances

Show CleanupOpts # |
Methods showsPrec :: Int -> CleanupOpts -> ShowS # show :: CleanupOpts -> String # showList :: [CleanupOpts] -> ShowS #

data CleanupAction #

Cleanup action.

Constructors

CleanupInteractive |
CleanupImmediate |
CleanupDryRun |

Instances

Show CleanupAction # |
Methods showsPrec :: Int -> CleanupAction -> ShowS # show :: CleanupAction -> String # showList :: [CleanupAction] -> ShowS #

dockerCleanupCmdName :: String #

Command-line argument for `docker cleanup`.

dockerCmdName :: String #

Command-line argument for "docker"

dockerHelpOptName :: String #

dockerPullCmdName :: String #

Command-line argument for `docker pull`.

entrypoint :: (MonadIO m, MonadBaseControl IO m, MonadCatch m, MonadLogger m) => Config -> DockerEntrypoint -> m () #

The Docker container "entrypoint": special actions performed when first entering a container, such as switching the UID/GID to the "outside-Docker" user's.

preventInContainer :: (MonadIO m, MonadThrow m) => m () -> m () #

Error if running in a container.

pull :: (StackM env m, HasConfig env) => m () #

Pull latest version of configured Docker image from registry.

reexecWithOptionalContainer :: (StackM env m, HasConfig env) => Maybe (Path Abs Dir) -> Maybe (m ()) -> IO () -> Maybe (m ()) -> Maybe (m ()) -> m () #

If Docker is enabled, re-runs the currently running OS command in a Docker container. Otherwise, runs the inner action.

This takes an optional release action which should be taken IFF control is transfering away from the current process to the intra-container one. The main use for this is releasing a lock. After launching reexecution, the host process becomes nothing but an manager for the call into docker and thus may not hold the lock.

reset :: (MonadIO m, MonadReader env m, HasConfig env) => Maybe (Path Abs Dir) -> Bool -> m () #

Remove the project's Docker sandbox.

reExecArgName :: String #

Command-line option for `--internal-re-exec-version`.

data StackDockerException #

Exceptions thrown by Stack.Docker.

Constructors

DockerMustBeEnabledException | Docker must be enabled to use the command.
OnlyOnHostException | Command must be run on host OS (not in a container).
InspectFailedException String | `docker inspect` failed.
NotPulledException String | Image does not exist.
InvalidCleanupCommandException String | Input to `docker cleanup` has invalid command.
InvalidImagesOutputException String | Invalid output from `docker images`.
InvalidPSOutputException String | Invalid output from `docker ps`.
InvalidInspectOutputException String | Invalid output from `docker inspect`.
PullFailedException String | Could not pull a Docker image.
DockerTooOldException Version Version | Installed version of `docker` below minimum version.
DockerVersionProhibitedException [Version] Version | Installed version of `docker` is prohibited.
BadDockerVersionException VersionRange Version | Installed version of `docker` is out of range specified in config file.
InvalidVersionOutputException | Invalid output from `docker --version`.
HostStackTooOldException Version (Maybe Version) | Version of `stack` on host is too old for version in image.
ContainerStackTooOldException Version Version | Version of `stack` in container/image is too old for version on host.
CannotDetermineProjectRootException | Can't determine the project root (where to put docker sandbox).
DockerNotInstalledException | `docker --version` failed.
UnsupportedStackExeHostPlatformException | Using host stack-exe on unsupported platform.
DockerStackExeParseException String | `stack-exe` option fails to parse.

Instances

Show StackDockerException # |
Methods showsPrec :: Int -> StackDockerException -> ShowS # show :: StackDockerException -> String # showList :: [StackDockerException] -> ShowS #
Exception StackDockerException # |
Methods toException :: StackDockerException -> SomeException # fromException :: SomeException -> Maybe StackDockerException # displayException :: StackDockerException -> String #