fix 2 docker bugs
This commit is contained in:
parent
a4eec61238
commit
2fd17d628c
|
@ -99,7 +99,7 @@ hasContainer hn cn findcontainer =
|
||||||
|
|
||||||
ensureContainer :: ContainerId -> Image -> [Containerized Property] -> IO Result
|
ensureContainer :: ContainerId -> Image -> [Containerized Property] -> IO Result
|
||||||
ensureContainer cid image containerprops = do
|
ensureContainer cid image containerprops = do
|
||||||
l <- listRunningContainers
|
l <- listContainers Running
|
||||||
if cid `elem` l
|
if cid `elem` l
|
||||||
then do
|
then do
|
||||||
runningident <- getrunningident
|
runningident <- getrunningident
|
||||||
|
@ -111,7 +111,8 @@ ensureContainer cid image containerprops = do
|
||||||
removeContainer cid
|
removeContainer cid
|
||||||
go oldimage
|
go oldimage
|
||||||
else do
|
else do
|
||||||
removeContainer cid
|
whenM (elem cid <$> listContainers Stopped) $
|
||||||
|
removeContainer cid
|
||||||
go image
|
go image
|
||||||
where
|
where
|
||||||
ident = ContainerIdent image cid runps
|
ident = ContainerIdent image cid runps
|
||||||
|
@ -199,14 +200,23 @@ commitContainer cid = catchMaybeIO $
|
||||||
takeWhile (/= '\n')
|
takeWhile (/= '\n')
|
||||||
<$> readProcess dockercmd ["commit", fromContainerId cid]
|
<$> readProcess dockercmd ["commit", fromContainerId cid]
|
||||||
|
|
||||||
|
data ContainerStatus = Running | Stopped
|
||||||
|
deriving (Eq)
|
||||||
|
|
||||||
-- | Only lists propellor managed containers.
|
-- | Only lists propellor managed containers.
|
||||||
listRunningContainers :: IO [ContainerId]
|
listContainers :: ContainerStatus -> IO [ContainerId]
|
||||||
listRunningContainers =
|
listContainers status =
|
||||||
catMaybes . map readish . catMaybes . map (lastMaybe . words) . lines
|
catMaybes . map readish . catMaybes . map (lastMaybe . words) . lines
|
||||||
<$> readProcess dockercmd ["ps", "--no-trunc"]
|
<$> readProcess dockercmd ps
|
||||||
|
where
|
||||||
|
ps
|
||||||
|
| status == Stopped = baseps ++ ["--all"]
|
||||||
|
| otherwise = baseps
|
||||||
|
baseps = ["ps", "--no-trunc"]
|
||||||
|
|
||||||
runProp :: String -> RunParam -> Containerized Property
|
runProp :: String -> RunParam -> Containerized Property
|
||||||
runProp field val = Containerized [param] (Property param (return NoChange))
|
runProp field val =
|
||||||
|
Containerized ["--" ++ param] (Property param (return NoChange))
|
||||||
where
|
where
|
||||||
param = field++"="++val
|
param = field++"="++val
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue