Skip to content

Commit

Permalink
Merge pull request #1321 from mwieczorek/f-windows-binds
Browse files Browse the repository at this point in the history
Volume binds for windows containers
  • Loading branch information
diptanu committed Jul 18, 2016
2 parents 3c68601 + ff6a5aa commit 51149e4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions client/allocdir/alloc_dir_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@ import (
"fmt"
"os"
"os/user"
"path/filepath"
"strconv"

"golang.org/x/sys/unix"
)

var (
//Path inside container for mounted directory shared across tasks in a task group.
SharedAllocContainerPath = filepath.Join("/", SharedAllocName)

//Path inside container for mounted directory for local storage.
TaskLocalContainerPath = filepath.Join("/", TaskLocal)
)

func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
// Attempt to hardlink.
if err := os.Link(src, dst); err == nil {
Expand Down
9 changes: 9 additions & 0 deletions client/allocdir/alloc_dir_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ package allocdir
import (
"errors"
"os"
"path/filepath"
)

var (
//Path inside container for mounted directory that is shared across tasks in a task group.
SharedAllocContainerPath = filepath.Join("c:\\", SharedAllocName)

//Path inside container for mounted directory for local storage.
TaskLocalContainerPath = filepath.Join("c:\\", TaskLocal)
)

func (d *AllocDir) linkOrCopy(src, dst string, perm os.FileMode) error {
Expand Down
8 changes: 4 additions & 4 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ func (d *DockerDriver) containerBinds(alloc *allocdir.AllocDir, task *structs.Ta
return nil, fmt.Errorf("Failed to find task local directory: %v", task.Name)
}

allocDirBind := fmt.Sprintf("%s:/%s", shared, allocdir.SharedAllocName)
taskLocalBind := fmt.Sprintf("%s:/%s", local, allocdir.TaskLocal)
allocDirBind := fmt.Sprintf("%s:%s", shared, allocdir.SharedAllocContainerPath)
taskLocalBind := fmt.Sprintf("%s:%s", local, allocdir.TaskLocalContainerPath)

if selinuxLabel := d.config.Read("docker.volumes.selinuxlabel"); selinuxLabel != "" {
allocDirBind = fmt.Sprintf("%s:%s", allocDirBind, selinuxLabel)
Expand Down Expand Up @@ -375,8 +375,8 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task,
}

// Set environment variables.
d.taskEnv.SetAllocDir(filepath.Join("/", allocdir.SharedAllocName))
d.taskEnv.SetTaskLocalDir(filepath.Join("/", allocdir.TaskLocal))
d.taskEnv.SetAllocDir(allocdir.SharedAllocContainerPath)
d.taskEnv.SetTaskLocalDir(allocdir.TaskLocalContainerPath)

config := &docker.Config{
Image: driverConfig.ImageName,
Expand Down

0 comments on commit 51149e4

Please sign in to comment.