You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/12/20 22:28:59 UTC
[5/5] mesos git commit: Windows: Changed the shell used by the docker
containerizer.
Windows: Changed the shell used by the docker containerizer.
This changes the command given to the Docker CLI when the CommandInfo
specifies `shell=true`. Instead of `/bin/sh -c`, the Windows command
will be `cmd /c`.
Review: https://reviews.apache.org/r/53716/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3755d37f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3755d37f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3755d37f
Branch: refs/heads/master
Commit: 3755d37f011a1f48ca9a6efe80b3bd79d5354609
Parents: 704654c
Author: Daniel Pravat <dp...@outlook.com>
Authored: Tue Dec 20 13:39:30 2016 -0800
Committer: Joseph Wu <jo...@apache.org>
Committed: Tue Dec 20 13:39:30 2016 -0800
----------------------------------------------------------------------
src/docker/docker.cpp | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/3755d37f/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index b2a547d..472cb1b 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -804,11 +804,16 @@ Future<Option<int>> 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
+ // assume the user intends to run the command within a shell
// and not the default entrypoint of the image. View MESOS-1770
// for more details.
argv.push_back("--entrypoint");
+
+#ifdef __WINDOWS__
+ argv.push_back("cmd");
+#else
argv.push_back("/bin/sh");
+#endif // __WINDOWS__
}
argv.push_back("--name");
@@ -820,10 +825,15 @@ Future<Option<int>> Docker::run(
return Failure("Shell specified but no command value provided");
}
- // 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.
+ // The Docker CLI only supports a single word for overriding the
+ // entrypoint, so we must specify `-c` (or `/c` on Windows)
+ // for the other parts of the command.
+#ifdef __WINDOWS__
+ argv.push_back("/c");
+#else
argv.push_back("-c");
+#endif // __WINDOWS__
+
argv.push_back(commandInfo.value());
} else {
if (commandInfo.has_value()) {