Pass the DOCKER_* env vars when running docker
authorFlavio Percoco <flaper87@gmail.com>
Wed, 1 Mar 2017 13:27:57 +0000 (14:27 +0100)
committerFlavio Percoco <flaper87@gmail.com>
Wed, 1 Mar 2017 14:16:30 +0000 (15:16 +0100)
We should always pass the `DOCKER_*` env vars to all the `docker`
commands that are executed in the various scripts as those variables may
contain the access data for the docker daemon.

Change-Id: Ie719f451350e6ea35cb22d97a8f090ad81fa8141

docker/docker-puppet.py

index d9496af..6cee68f 100755 (executable)
@@ -207,6 +207,11 @@ def mp_puppet_config((config_volume, puppet_tags, manifest, config_image, volume
         dcmd.extend(['--entrypoint', sh_script])
 
         env = {}
+        # NOTE(flaper87): Always copy the DOCKER_* environment variables as
+        # they contain the access data for the docker daemon.
+        for k in filter(lambda k: k.startswith('DOCKER'), os.environ.keys()):
+            env[k] = os.environ.get(k)
+
         if os.environ.get('NET_HOST', 'false') == 'true':
             print('NET_HOST enabled')
             dcmd.extend(['--net', 'host', '--volume',