diff options
| author | Joey Hess <joey@kitenet.net> | 2014-06-01 13:35:21 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-06-01 13:35:21 -0400 |
| commit | c224625734fb4b6ae11f6fdd897ed83fc7f7bab5 (patch) | |
| tree | 84683810e856b6a7dee6d9bec6e88bba3a9fad8a | |
| parent | 527fff74c39a551a07a241aea671cec41645ebee (diff) | |
propellor spin
| -rw-r--r-- | config-joey.hs | 2 | ||||
| -rw-r--r-- | src/Propellor/Property/Docker.hs | 25 |
2 files changed, 25 insertions, 2 deletions
diff --git a/config-joey.hs b/config-joey.hs index 9f5005b3..3f0d5154 100644 --- a/config-joey.hs +++ b/config-joey.hs @@ -224,7 +224,7 @@ hosts = -- (o) ` in GitAnnexBuilder.androidContainer dockerImage "android-git-annex" doNothing gitannexdir & Docker.volume ("/home/joey/src/git-annex:" ++ gitannexdir) - -- temp for an aqquantance + -- temp for an accuantance , standardContainer "voltagex" Stable "amd64" & Docker.publish "22022:22" & Apt.serviceInstalledRunning "ssh" diff --git a/src/Propellor/Property/Docker.hs b/src/Propellor/Property/Docker.hs index fbf34965..adaea548 100644 --- a/src/Propellor/Property/Docker.hs +++ b/src/Propellor/Property/Docker.hs @@ -11,6 +11,7 @@ module Propellor.Property.Docker ( configured, container, docked, + memoryLimited, garbageCollected, Image, ContainerName, @@ -25,6 +26,7 @@ module Propellor.Property.Docker ( volumes_from, workdir, memory, + cpuShares, link, ContainerAlias, -- * Internal use @@ -170,6 +172,20 @@ garbageCollected = propertyList "docker garbage collected" gcimages = property "docker images garbage collected" $ do liftIO $ report <$> (mapM removeImage =<< listImages) +-- | Configures the kernel to respect docker memory limits. +-- +-- This assumes the system boots using grub 2. And that you don't need any +-- other GRUB_CMDLINE_LINUX_DEFAULT settings. +-- +-- Only takes effect after reboot. (Not automated.) +memoryLimited :: Property +memoryLimited = "/etc/default/grub" `File.containsLine` cfg + `describe` "docker memory limited" + `onChange` cmdProperty "update-grub" [] + where + cmdline = "cgroup_enable=memory swapaccount=1" + cfg = "GRUB_CMDLINE_LINUX_DEFAULT=\""++cmdline++"\"" + data Container = Container Image [RunParam] -- | Parameters to pass to `docker run` when creating a container. @@ -220,10 +236,17 @@ workdir :: String -> Property workdir = runProp "workdir" -- | Memory limit for container. ---Format: <number><optional unit>, where unit = b, k, m or g +-- Format: <number><optional unit>, where unit = b, k, m or g +-- +-- Note: Only takes effect when the host has the memoryLimited property +-- enabled. memory :: String -> Property memory = runProp "memory" +-- | CPU shares (relative weight). +cpuShares :: Int -> Property +cpuShares = runProp "cpu-shares" . show + -- | Link with another container on the same host. link :: ContainerName -> ContainerAlias -> Property link linkwith calias = genProp "link" $ \hn -> |
