Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #233 from vania-pooh/master
Browse files Browse the repository at this point in the history
Better mounting Docker socket on Windows
  • Loading branch information
vania-pooh authored Aug 5, 2019
2 parents e16925e + c27b353 commit 49a7f90
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions selenoid/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ func (c *DockerConfigurator) Start() error {
fmt.Sprintf("%s:/opt/selenoid/logs:Z", logsConfigDir),
}
const dockerSocket = "/var/run/docker.sock"
if c.isDockerForWindows() {
if isWindows() {
//With two slashes. See https://stackoverflow.com/questions/36765138/bind-to-docker-socket-on-windows
volumes = append(volumes, fmt.Sprintf("/%s:%s", dockerSocket, dockerSocket))
} else if fileExists(dockerSocket) {
Expand Down Expand Up @@ -705,15 +705,6 @@ func (c *DockerConfigurator) Start() error {
return c.startContainer(cfg)
}

func (c *DockerConfigurator) isDockerForWindows() bool {
info, err := c.docker.Info(context.Background())
if err != nil {
c.Pointf("Failed to determine whether this is Docker for Windows: %v", err)
return false
}
return strings.Contains(info.OSType, "linux") && strings.Contains(strings.ToLower(info.OperatingSystem), "windows")
}

func isVideoRecordingSupported(logger Logger, version string) bool {
return isVersion(version, ">= 1.4.0", func(version string) {
logger.Pointf(`Not enabling video feature because specified version "%s" is not semantic`, version)
Expand All @@ -739,9 +730,13 @@ func isLogSavingSupported(logger Logger, version string) bool {
})
}

func isWindows() bool {
return runtime.GOOS == "windows"
}

func getVolumeConfigDir(defaultConfigDir string, elem []string) string {
configDir := chooseVolumeConfigDir(defaultConfigDir, elem)
if runtime.GOOS == "windows" { //A bit ugly, but conditional compilation is even worse
if isWindows() { //A bit ugly, but conditional compilation is even worse
return postProcessPath(configDir)
}
return configDir
Expand Down

0 comments on commit 49a7f90

Please sign in to comment.