From 43a3584a5c651da67466027c1a065fe746b8c855 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 15 Jun 2016 10:12:32 +0200 Subject: [PATCH] Pass by default the environment variable container=docker Fix #573 --- gns3server/modules/docker/docker_vm.py | 2 +- tests/modules/docker/test_docker_vm.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gns3server/modules/docker/docker_vm.py b/gns3server/modules/docker/docker_vm.py index 31ff5fbb..8994e744 100644 --- a/gns3server/modules/docker/docker_vm.py +++ b/gns3server/modules/docker/docker_vm.py @@ -275,7 +275,7 @@ class DockerVM(BaseVM): "Binds": self._mount_binds(image_infos) }, "Volumes": {}, - "Env": [], + "Env": ["container=docker"], # Systemd compliant: https://github.com/GNS3/gns3-server/issues/573 "Cmd": [], "Entrypoint": image_infos.get("Config", {"Entrypoint": []})["Entrypoint"] } diff --git a/tests/modules/docker/test_docker_vm.py b/tests/modules/docker/test_docker_vm.py index 1849d7c8..6f0327e7 100644 --- a/tests/modules/docker/test_docker_vm.py +++ b/tests/modules/docker/test_docker_vm.py @@ -104,6 +104,7 @@ def test_create(loop, project, manager): "Hostname": "test", "Image": "ubuntu:latest", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network" ], @@ -142,6 +143,7 @@ def test_create_with_tag(loop, project, manager): "Hostname": "test", "Image": "ubuntu:latest:16.04", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network" ], @@ -184,6 +186,7 @@ def test_create_vnc(loop, project, manager): "Hostname": "test", "Image": "ubuntu:latest", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network", "DISPLAY=:42" @@ -228,6 +231,7 @@ def test_create_start_cmd(loop, project, manager): "Hostname": "test", "Image": "ubuntu:latest", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network" ] @@ -260,6 +264,7 @@ def test_create_environment(loop, project, manager): "Privileged": True }, "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network", "YES=1", @@ -320,6 +325,7 @@ def test_create_image_not_available(loop, project, manager): "Hostname": "test", "Image": "ubuntu:latest", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network" ], @@ -540,6 +546,7 @@ def test_update(loop, vm): "Hostname": "test", "Image": "ubuntu:latest", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network" ], @@ -608,6 +615,7 @@ def test_update_running(loop, vm): "Hostname": "test", "Image": "ubuntu:latest", "Env": [ + "container=docker", "GNS3_MAX_ETHERNET=eth0", "GNS3_VOLUMES=/etc/network" ],