You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/09/17 17:53:54 UTC

git commit: Override entrypoint when shell enabled in Docker.

Repository: mesos
Updated Branches:
  refs/heads/master 1453a4775 -> cc9fd8124


Override entrypoint when shell enabled in Docker.

Review: https://reviews.apache.org/r/25403


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/cc9fd812
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/cc9fd812
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/cc9fd812

Branch: refs/heads/master
Commit: cc9fd81243bdcbf468a2d8cbcb22e6527335bf00
Parents: 1453a47
Author: Timothy Chen <tn...@apache.org>
Authored: Wed Sep 17 08:49:38 2014 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Wed Sep 17 08:50:22 2014 -0700

----------------------------------------------------------------------
 src/docker/docker.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/cc9fd812/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index a8becb8..1dd3dd1 100644
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -365,6 +365,15 @@ Future<Nothing> Docker::run(
     }
   }
 
+  if (commandInfo.shell()) {
+    // We override the entrypoint if shell is enabled because we
+    // assume the user intends to run the command within /bin/sh
+    // and not the default entrypoint of the image. View MESOS-1770
+    // for more details.
+    argv.push_back("--entrypoint");
+    argv.push_back("/bin/sh");
+  }
+
   argv.push_back("--name");
   argv.push_back(name);
   argv.push_back(image);
@@ -373,7 +382,10 @@ Future<Nothing> Docker::run(
     if (!commandInfo.has_value()) {
       return Failure("Shell specified but no command value provided");
     }
-    argv.push_back("/bin/sh");
+
+    // Adding -c here because Docker cli only supports a single word
+    // for overriding entrypoint, so adding the -c flag for /bin/sh
+    // as part of the command.
     argv.push_back("-c");
     argv.push_back(commandInfo.value());
   } else {