You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/07/22 23:54:05 UTC

[3/5] mesos git commit: Supported relative container path in docker containerizer.

Supported relative container path in docker containerizer.

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


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

Branch: refs/heads/1.0.x
Commit: 3d807e8ddb26b5053b013a92ba90470b7b14c9fd
Parents: b7724d9
Author: Gilbert Song <so...@gmail.com>
Authored: Wed Jul 13 15:52:12 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jul 22 16:42:40 2016 -0700

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/3d807e8d/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index 880b25a..c6f7d78 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -557,10 +557,24 @@ Future<Option<int>> Docker::run(
 
   Option<string> volumeDriver;
   foreach (const Volume& volume, containerInfo.volumes()) {
-    string volumeConfig = volume.container_path();
+    // The 'container_path' can be either an absolute path or a
+    // relative path. If it is a relative path, it would be prefixed
+    // with the container sandbox directory.
+    string volumeConfig = strings::startsWith(volume.container_path(), "/")
+      ? volume.container_path()
+      : path::join(mappedDirectory, volume.container_path());
 
     // TODO(gyliu513): Set `host_path` as source.
     if (volume.has_host_path()) {
+      // If both 'host_path' and 'container_path' are relative paths,
+      // return a failure because the user can just directly access the
+      // volume in the sandbox.
+      if (!strings::startsWith(volume.host_path(), "/") &&
+          !strings::startsWith(volume.container_path(), "/")) {
+        return Failure(
+            "Both 'host_path' and 'container_path' of a volume are relative");
+      }
+
       if (!strings::startsWith(volume.host_path(), "/") &&
           !dockerInfo.has_volume_driver()) {
         // When volume dirver is empty and host path is a relative path, mapping