Skip to content

Commit

Permalink
Fix Windows volume mount containing backslash (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
dblanchette authored Mar 9, 2021
1 parent 9490701 commit 8548500
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,23 @@ func (docker *dockerConfig) call() int {
// If temp location is not disabled, we persist the home folder in a docker volume
imageSummary := getImageSummary(imageName)
image := inspectImage(imageSummary.ID)
user := currentUser.Username
username := currentUser.Username

if image.Config.User != "" {
// If an explicit user is defined in the image, we use that user instead of the actual one
// This ensure to not mount a folder with no permission to write into it
user = image.Config.User
username = image.Config.User
}
homePath := fmt.Sprintf("/home/%s", user)

// Fix for Windows containing the domain name in the Username (e.g. ACME\jsmith)
// The backslash is not accepted for a Docker volume path
splitUsername := strings.Split(username, "\\")
username = splitUsername[len(splitUsername) - 1]

homePath := fmt.Sprintf("/home/%s", username)
dockerArgs = append(dockerArgs,
"-e", fmt.Sprintf("HOME=%s", homePath),
"-v", fmt.Sprintf("%s-%s:%s", dockerVolumeName, user, homePath),
"-v", fmt.Sprintf("%s-%s:%s", dockerVolumeName, username, homePath),
)
}

Expand Down

0 comments on commit 8548500

Please sign in to comment.