mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Resolve conflicts with restart policies
Signed-off-by: Tibor Vass <teabee89@gmail.com>
This commit is contained in:
parent
22eb3a3a50
commit
e49c701092
2 changed files with 16 additions and 17 deletions
|
@ -2099,10 +2099,11 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Detached mode: run the container in the background and print the new container ID")
|
flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Detached mode: run the container in the background and print the new container ID")
|
||||||
flSigProxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy received signals to the process (even in non-TTY mode). SIGCHLD, SIGSTOP, and SIGKILL are not proxied.")
|
flSigProxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy received signals to the process (even in non-TTY mode). SIGCHLD, SIGSTOP, and SIGKILL are not proxied.")
|
||||||
flName = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container")
|
flName = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container")
|
||||||
|
flAttach *opts.ListOpts
|
||||||
|
|
||||||
flAttach *opts.ListOpts
|
ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d")
|
||||||
|
ErrConflictRestartPolicyAndAutoRemove = fmt.Errorf("Conflicting options: --restart and --rm")
|
||||||
ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d")
|
ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
|
||||||
)
|
)
|
||||||
|
|
||||||
config, hostConfig, cmd, err := runconfig.ParseSubcommand(cmd, args, nil)
|
config, hostConfig, cmd, err := runconfig.ParseSubcommand(cmd, args, nil)
|
||||||
|
@ -2118,11 +2119,11 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
if fl := cmd.Lookup("attach"); fl != nil {
|
if fl := cmd.Lookup("attach"); fl != nil {
|
||||||
flAttach = fl.Value.(*opts.ListOpts)
|
flAttach = fl.Value.(*opts.ListOpts)
|
||||||
if flAttach.Len() != 0 {
|
if flAttach.Len() != 0 {
|
||||||
return fmt.Errorf("Conflicting options: -a and -d")
|
return ErrConflictAttachDetach
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if *flAutoRemove {
|
if *flAutoRemove {
|
||||||
return fmt.Errorf("Conflicting options: --rm and -d")
|
return ErrConflictDetachAutoRemove
|
||||||
}
|
}
|
||||||
|
|
||||||
config.AttachStdin = false
|
config.AttachStdin = false
|
||||||
|
@ -2161,6 +2162,10 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *flAutoRemove && (hostConfig.RestartPolicy.Name == "always" || hostConfig.RestartPolicy.Name == "on-failure") {
|
||||||
|
return ErrConflictRestartPolicyAndAutoRemove
|
||||||
|
}
|
||||||
|
|
||||||
// We need to instanciate the chan because the select needs it. It can
|
// We need to instanciate the chan because the select needs it. It can
|
||||||
// be closed but can't be uninitialized.
|
// be closed but can't be uninitialized.
|
||||||
hijacked := make(chan io.Closer)
|
hijacked := make(chan io.Closer)
|
||||||
|
|
|
@ -17,14 +17,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
|
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.")
|
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.")
|
ErrConflictContainerNetworkAndDns = fmt.Errorf("Conflicting options: --net=container can't be used with --dns. This configuration is invalid.")
|
||||||
ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
|
ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
|
||||||
ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
|
ErrConflictHostNetworkAndDns = fmt.Errorf("Conflicting options: --net=host can't be used with --dns. This configuration is invalid.")
|
||||||
ErrConflictHostNetworkAndDns = fmt.Errorf("Conflicting options: --net=host can't be used with --dns. This configuration is invalid.")
|
ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior.")
|
||||||
ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior.")
|
|
||||||
ErrConflictRestartPolicyAndAutoRemove = fmt.Errorf("Conflicting options: --restart and --rm")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// FIXME Only used in tests
|
// FIXME Only used in tests
|
||||||
|
@ -247,10 +245,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
||||||
return nil, nil, cmd, err
|
return nil, nil, cmd, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flAutoRemove && (restartPolicy.Name == "always" || restartPolicy.Name == "on-failure") {
|
|
||||||
return nil, nil, cmd, ErrConflictRestartPolicyAndAutoRemove
|
|
||||||
}
|
|
||||||
|
|
||||||
config := &Config{
|
config := &Config{
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
Domainname: domainname,
|
Domainname: domainname,
|
||||||
|
|
Loading…
Reference in a new issue