Merge pull request #12772 from Microsoft/10662-moveworkdirchecktoserver
Windows: Move workdir check daemon-side
This commit is contained in:
commit
79d086c47d
2 changed files with 9 additions and 8 deletions
|
@ -2,6 +2,7 @@ package daemon
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/docker/docker/graph"
|
||||
"github.com/docker/docker/image"
|
||||
|
@ -16,6 +17,13 @@ func (daemon *Daemon) ContainerCreate(name string, config *runconfig.Config, hos
|
|||
return "", warnings, err
|
||||
}
|
||||
|
||||
// The check for a valid workdir path is made on the server rather than in the
|
||||
// client. This is because we don't know the type of path (Linux or Windows)
|
||||
// to validate on the client.
|
||||
if config.WorkingDir != "" && !filepath.IsAbs(config.WorkingDir) {
|
||||
return "", warnings, fmt.Errorf("The working directory '%s' is invalid. It needs to be an absolute path.", config.WorkingDir)
|
||||
}
|
||||
|
||||
container, buildWarnings, err := daemon.Create(config, hostConfig, name)
|
||||
if err != nil {
|
||||
if daemon.Graph().IsNotExist(err, config.Image) {
|
||||
|
|
|
@ -2,7 +2,6 @@ package runconfig
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
|
@ -15,7 +14,6 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
|
||||
ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior.")
|
||||
ErrConflictContainerNetworkAndDns = fmt.Errorf("Conflicting options: --net=container can't be used with --dns. This configuration is invalid.")
|
||||
ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
|
||||
|
@ -101,12 +99,7 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
|
|||
return nil, nil, cmd, err
|
||||
}
|
||||
|
||||
// Validate input params
|
||||
if *flWorkingDir != "" && !path.IsAbs(*flWorkingDir) {
|
||||
return nil, nil, cmd, ErrInvalidWorkingDirectory
|
||||
}
|
||||
|
||||
// Validate the input mac address
|
||||
// Validate input params starting with the input mac address
|
||||
if *flMacAddress != "" {
|
||||
if _, err := opts.ValidateMACAddress(*flMacAddress); err != nil {
|
||||
return nil, nil, cmd, fmt.Errorf("%s is not a valid mac address", *flMacAddress)
|
||||
|
|
Loading…
Reference in a new issue