diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-02 13:56:16 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-02 13:56:16 -0400 |
| commit | 9cde582c3599f32917f64664a440b5bc5b7f36c4 (patch) | |
| tree | 3034e7b538755e66a428ec2b3cf443fa088f09b7 | |
| parent | 6456ce3cc008e0671a1a5c2b723ae833aac4a9d8 (diff) | |
better container reversion
| -rw-r--r-- | Propellor/Property/Docker.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Propellor/Property/Docker.hs b/Propellor/Property/Docker.hs index 0cec9e1e..e9715cad 100644 --- a/Propellor/Property/Docker.hs +++ b/Propellor/Property/Docker.hs @@ -55,7 +55,7 @@ docked findc hn cn = findContainer findc hn cn $ teardown = Property ("undocked " ++ fromContainerId cid) $ report <$> mapM id - [ stopContainer cid + [ stopContainerIfRunning cid , removeContainer cid , removeImage image ] @@ -337,6 +337,12 @@ provisionContainer cid = containerDesc cid $ Property "provision" $ do stopContainer :: ContainerId -> IO Bool stopContainer cid = boolSystem dockercmd [Param "stop", Param $ fromContainerId cid ] +stopContainerIfRunning :: ContainerId -> IO Bool +stopContainerIfRunning cid = ifM (elem cid <$> listContainers RunningContainers) + ( stopContainer cid + , return True + ) + removeContainer :: ContainerId -> IO Bool removeContainer cid = catchBoolIO $ snd <$> processTranscript dockercmd ["rm", fromContainerId cid ] Nothing |
