From 11a2100d537319361f9515414e10ebd55bbb9ac4 Mon Sep 17 00:00:00 2001
From: Steven Dake <stdake@cisco.com>
Date: Tue, 24 Feb 2015 06:39:06 -0700
Subject: [PATCH 1/2] Add a --pid=host feature to expose the host PID space to
 the container

Docker 1.5.0+ introduces a --pid=host feature which allows sharing of PID
namespaces between baremetal and containers.  This is useful for atomic
upgrades, atomic rollbacks, and monitoring.

For more details of a real-life use case, check out:
http://sdake.io/2015/01/28/an-atomic-upgrade-process-for-openstack-compute-nodes/

Signed-off-by: Steven Dake <stdake@cisco.com>
---
 docs/yml.md | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/docs/yml.md b/docs/yml.md
index a9909e816..f8191766a 100644
--- a/docs/yml.md
+++ b/docs/yml.md
@@ -264,6 +264,16 @@ net: "none"
 net: "container:[name or id]"
 net: "host"
 ```
+### pid
+
+```
+pid: "host"
+```
+
+Sets the PID mode to the host PID mode.  This turns on sharing between
+container and the host operating system the PID address space.  Containers
+launched with this flag will be able to access and manipulate other
+containers in the bare-metal machine's namespace and vise-versa.
 
 ### dns
 

From 94277a3eb052c1bef77e95f0d12bcf5f3c327038 Mon Sep 17 00:00:00 2001
From: Steven Dake <stdake@cisco.com>
Date: Tue, 24 Feb 2015 22:42:23 -0700
Subject: [PATCH 2/2] Add --pid=host support

Allow docker-compsoe to use the docker --pid=host API available in 1.17

Signed-off-by: Steven Dake <stdake@cisco.com>
---
 compose/config.py                 |  1 +
 compose/service.py                |  3 +++
 tests/integration/service_test.py | 11 +++++++++++
 3 files changed, 15 insertions(+)

diff --git a/compose/config.py b/compose/config.py
index 2c2ddf633..6ef637c5a 100644
--- a/compose/config.py
+++ b/compose/config.py
@@ -20,6 +20,7 @@ DOCKER_CONFIG_KEYS = [
     'links',
     'mem_limit',
     'net',
+    'pid',
     'ports',
     'privileged',
     'restart',
diff --git a/compose/service.py b/compose/service.py
index 936e3f9d0..20955d235 100644
--- a/compose/service.py
+++ b/compose/service.py
@@ -25,6 +25,7 @@ DOCKER_START_KEYS = [
     'dns_search',
     'env_file',
     'net',
+    'pid',
     'privileged',
     'restart',
 ]
@@ -434,6 +435,7 @@ class Service(object):
         privileged = options.get('privileged', False)
         cap_add = options.get('cap_add', None)
         cap_drop = options.get('cap_drop', None)
+        pid = options.get('pid', None)
 
         dns = options.get('dns', None)
         if isinstance(dns, six.string_types):
@@ -457,6 +459,7 @@ class Service(object):
             restart_policy=restart,
             cap_add=cap_add,
             cap_drop=cap_drop,
+            pid_mode=pid
         )
 
     def _get_image_name(self, image):
diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py
index 066f8b095..85f6db9db 100644
--- a/tests/integration/service_test.py
+++ b/tests/integration/service_test.py
@@ -419,6 +419,17 @@ class ServiceTest(DockerClientTestCase):
         container = create_and_start_container(service)
         self.assertEqual(container.get('HostConfig.NetworkMode'), 'host')
 
+    def test_pid_mode_none_defined(self):
+        service = self.create_service('web', pid=None)
+        container = create_and_start_container(service)
+        print 'STEAK %s' % (container.get('HostConfig.PidMode'))
+        self.assertEqual(container.get('HostConfig.PidMode'), '')
+
+    def test_pid_mode_host(self):
+        service = self.create_service('web', pid='host')
+        container = create_and_start_container(service)
+        self.assertEqual(container.get('HostConfig.PidMode'), 'host')
+
     def test_dns_no_value(self):
         service = self.create_service('web')
         container = create_and_start_container(service)