From 1dd437ecdcd9eaf7a7d18d8f623bd70b98690a01 Mon Sep 17 00:00:00 2001 From: Bernhard Ehlers Date: Thu, 3 Mar 2016 09:12:36 +0100 Subject: [PATCH] updated docker command line processing --- gns3server/modules/docker/docker_vm.py | 20 +++++++++++++------- gns3server/modules/docker/resources/init.sh | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) mode change 100644 => 100755 gns3server/modules/docker/resources/init.sh diff --git a/gns3server/modules/docker/docker_vm.py b/gns3server/modules/docker/docker_vm.py index 55fc04d5..3ae58910 100644 --- a/gns3server/modules/docker/docker_vm.py +++ b/gns3server/modules/docker/docker_vm.py @@ -195,16 +195,22 @@ class DockerVM(BaseVM): }, "Volumes": {}, "Env": [], - "Cmd": image_infos.get("ContainerConfig", {"Cmd": []})["Cmd"] + "Cmd": [], + "Entrypoint": image_infos.get("Config", {"Entrypoint": []})["Entrypoint"] } - params["Cmd"].insert(0, "/bin/sh") - params["Cmd"].insert(1, "/gns3/init.sh") + + if params["Entrypoint"] is None: + params["Entrypoint"] = [] if self._start_command: - params["Cmd"] += shlex.split(self._start_command) - else: - if len(params["Cmd"]) == 2: - params["Cmd"] += ["/bin/sh"] + params["Cmd"] = shlex.split(self._start_command) + if len(params["Cmd"]) == 0: + params["Cmd"] = image_infos.get("Config", {"Cmd": []})["Cmd"] + if params["Cmd"] is None: + params["Cmd"] = [] + if len(params["Cmd"]) == 0 and len(params["Entrypoint"]) == 0: + params["Cmd"] = ["/bin/sh"] + params["Entrypoint"].insert(0, "/gns3/init.sh") if self._environment: params["Env"] += [e.strip() for e in self._environment.split("\n")] diff --git a/gns3server/modules/docker/resources/init.sh b/gns3server/modules/docker/resources/init.sh old mode 100644 new mode 100755 index d120e395..abd3aa4f --- a/gns3server/modules/docker/resources/init.sh +++ b/gns3server/modules/docker/resources/init.sh @@ -43,4 +43,4 @@ sed -n 's/^ *\(eth[0-9]*\):.*/\1/p' < /proc/net/dev | while read dev; do done # continue normal docker startup -/bin/sh -c "$@" +exec "$@"