mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #14559 from Microsoft/10662-todo1
Windows: Move daemon check back centrally
This commit is contained in:
commit
b0da494aa3
3 changed files with 9 additions and 18 deletions
|
@ -43,8 +43,7 @@ var (
|
||||||
validContainerNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
|
validContainerNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]`
|
||||||
validContainerNamePattern = regexp.MustCompile(`^/?` + validContainerNameChars + `+$`)
|
validContainerNamePattern = regexp.MustCompile(`^/?` + validContainerNameChars + `+$`)
|
||||||
|
|
||||||
// TODO Windows. Change this once daemon is up and running.
|
ErrSystemNotSupported = errors.New("The Docker daemon is not supported on this platform.")
|
||||||
ErrSystemNotSupported = errors.New("The Docker daemon is only supported on linux")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type contStore struct {
|
type contStore struct {
|
||||||
|
@ -562,7 +561,12 @@ func NewDaemon(config *Config, registryService *registry.Service) (daemon *Daemo
|
||||||
// Do we have a disabled network?
|
// Do we have a disabled network?
|
||||||
config.DisableBridge = isBridgeNetworkDisabled(config)
|
config.DisableBridge = isBridgeNetworkDisabled(config)
|
||||||
|
|
||||||
// Check that the system is supported and we have sufficient privileges
|
// Verify the platform is supported as a daemon
|
||||||
|
if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
|
||||||
|
return nil, ErrSystemNotSupported
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate platform-specific requirements
|
||||||
if err := checkSystem(); err != nil {
|
if err := checkSystem(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
@ -197,13 +196,8 @@ func checkConfigOptions(config *Config) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkSystem validates the system is supported and we have sufficient privileges
|
// checkSystem validates platform-specific requirements
|
||||||
func checkSystem() error {
|
func checkSystem() error {
|
||||||
// TODO Windows. Once daemon is running on Windows, move this code back to
|
|
||||||
// NewDaemon() in daemon.go, and extend the check to support Windows.
|
|
||||||
if runtime.GOOS != "linux" {
|
|
||||||
return ErrSystemNotSupported
|
|
||||||
}
|
|
||||||
if os.Geteuid() != 0 {
|
if os.Geteuid() != 0 {
|
||||||
return fmt.Errorf("The Docker daemon needs to be run as root")
|
return fmt.Errorf("The Docker daemon needs to be run as root")
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package daemon
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
@ -82,16 +81,10 @@ func checkConfigOptions(config *Config) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkSystem validates the system is supported and we have sufficient privileges
|
// checkSystem validates platform-specific requirements
|
||||||
func checkSystem() error {
|
func checkSystem() error {
|
||||||
var dwVersion uint32
|
var dwVersion uint32
|
||||||
|
|
||||||
// TODO Windows. Once daemon is running on Windows, move this code back to
|
|
||||||
// NewDaemon() in daemon.go, and extend the check to support Windows.
|
|
||||||
if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
|
|
||||||
return ErrSystemNotSupported
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO Windows. May need at some point to ensure have elevation and
|
// TODO Windows. May need at some point to ensure have elevation and
|
||||||
// possibly LocalSystem.
|
// possibly LocalSystem.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue