Support environment variables without values
See https://github.com/docker/compose/pull/2997 for some context.

docker-py assumes that all variables should have an `=` but the docker-cli passes environment variables without values as just the key, which is super weird, but apparently swarm is relying on that currently.

diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index 6fcf037a..bde18b6b 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -821,6 +821,14 @@ def split_command(command):
     return shlex.split(command)
 
 
+def format_environment(environment):
+    def format_env(key, value):
+        if not value:
+            return key
+        return '{key}={value}'.format(key=key, value=value)
+    return [format_env(*var) for var in six.iteritems(environment)]
+
+
 def create_container_config(
     version, image, command, hostname=None, user=None, detach=False,
     stdin_open=False, tty=False, mem_limit=None, ports=None, environment=None,
@@ -836,10 +844,7 @@ def create_container_config(
         entrypoint = split_command(entrypoint)
 
     if isinstance(environment, dict):
-        environment = [
-            six.text_type('{0}={1}').format(k, v)
-            for k, v in six.iteritems(environment)
-        ]
+        environment = format_environment(environment)
 
     if labels is not None and compare_version('1.18', version) < 0:
         raise errors.InvalidVersion(
diff --git a/tests/integration/container_test.py b/tests/integration/container_test.py
index 1714599b..eb5b7467 100644
--- a/tests/integration/container_test.py
+++ b/tests/integration/container_test.py
@@ -370,6 +370,16 @@ class CreateContainerTest(helpers.BaseTestCase):
         self.assertRaises(ValueError,
                           self.client.create_host_config, pid_mode='40')
 
+    def test_create_with_environment_variable_no_value(self):
+        container = self.client.create_container(
+            BUSYBOX,
+            ['echo'],
+            environment={'Foo': None, 'Other': 'one'},
+        )
+        self.tmp_containers.append(container['Id'])
+        config = self.client.inspect_container(container['Id'])
+        assert sorted(config['Config']['Env']) == sorted(['Foo', 'Other=one'])
+
 
 class VolumeBindTest(helpers.BaseTestCase):
     def setUp(self):
['tests/integration/container_test.py', 'docker/utils/utils.py']