Signed-off-by: Tibor Vass <teabee89@gmail.com>
| ... | ... |
@@ -2099,10 +2099,11 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
| 2099 | 2099 |
flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Detached mode: run the container in the background and print the new container ID")
|
| 2100 | 2100 |
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.")
|
| 2101 | 2101 |
flName = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container")
|
| 2102 |
+ flAttach *opts.ListOpts |
|
| 2102 | 2103 |
|
| 2103 |
- flAttach *opts.ListOpts |
|
| 2104 |
- |
|
| 2105 |
- ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d")
|
|
| 2104 |
+ ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d")
|
|
| 2105 |
+ ErrConflictRestartPolicyAndAutoRemove = fmt.Errorf("Conflicting options: --restart and --rm")
|
|
| 2106 |
+ ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
|
|
| 2106 | 2107 |
) |
| 2107 | 2108 |
|
| 2108 | 2109 |
config, hostConfig, cmd, err := runconfig.ParseSubcommand(cmd, args, nil) |
| ... | ... |
@@ -2118,11 +2119,11 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
| 2118 | 2118 |
if fl := cmd.Lookup("attach"); fl != nil {
|
| 2119 | 2119 |
flAttach = fl.Value.(*opts.ListOpts) |
| 2120 | 2120 |
if flAttach.Len() != 0 {
|
| 2121 |
- return fmt.Errorf("Conflicting options: -a and -d")
|
|
| 2121 |
+ return ErrConflictAttachDetach |
|
| 2122 | 2122 |
} |
| 2123 | 2123 |
} |
| 2124 | 2124 |
if *flAutoRemove {
|
| 2125 |
- return fmt.Errorf("Conflicting options: --rm and -d")
|
|
| 2125 |
+ return ErrConflictDetachAutoRemove |
|
| 2126 | 2126 |
} |
| 2127 | 2127 |
|
| 2128 | 2128 |
config.AttachStdin = false |
| ... | ... |
@@ -2161,6 +2162,10 @@ func (cli *DockerCli) CmdRun(args ...string) error {
|
| 2161 | 2161 |
}() |
| 2162 | 2162 |
} |
| 2163 | 2163 |
|
| 2164 |
+ if *flAutoRemove && (hostConfig.RestartPolicy.Name == "always" || hostConfig.RestartPolicy.Name == "on-failure") {
|
|
| 2165 |
+ return ErrConflictRestartPolicyAndAutoRemove |
|
| 2166 |
+ } |
|
| 2167 |
+ |
|
| 2164 | 2168 |
// We need to instanciate the chan because the select needs it. It can |
| 2165 | 2169 |
// be closed but can't be uninitialized. |
| 2166 | 2170 |
hijacked := make(chan io.Closer) |
| ... | ... |
@@ -17,14 +17,12 @@ import ( |
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 | 19 |
var ( |
| 20 |
- ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
|
|
| 21 |
- ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior.")
|
|
| 22 |
- ErrConflictContainerNetworkAndDns = fmt.Errorf("Conflicting options: --net=container can't be used with --dns. This configuration is invalid.")
|
|
| 23 |
- ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
|
|
| 24 |
- ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
|
|
| 25 |
- ErrConflictHostNetworkAndDns = fmt.Errorf("Conflicting options: --net=host can't be used with --dns. This configuration is invalid.")
|
|
| 26 |
- ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior.")
|
|
| 27 |
- ErrConflictRestartPolicyAndAutoRemove = fmt.Errorf("Conflicting options: --restart and --rm")
|
|
| 20 |
+ ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
|
|
| 21 |
+ ErrConflictContainerNetworkAndLinks = fmt.Errorf("Conflicting options: --net=container can't be used with links. This would result in undefined behavior.")
|
|
| 22 |
+ ErrConflictContainerNetworkAndDns = fmt.Errorf("Conflicting options: --net=container can't be used with --dns. This configuration is invalid.")
|
|
| 23 |
+ ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
|
|
| 24 |
+ ErrConflictHostNetworkAndDns = fmt.Errorf("Conflicting options: --net=host can't be used with --dns. This configuration is invalid.")
|
|
| 25 |
+ ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior.")
|
|
| 28 | 26 |
) |
| 29 | 27 |
|
| 30 | 28 |
// FIXME Only used in tests |
| ... | ... |
@@ -247,10 +245,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf |
| 247 | 247 |
return nil, nil, cmd, err |
| 248 | 248 |
} |
| 249 | 249 |
|
| 250 |
- if *flAutoRemove && (restartPolicy.Name == "always" || restartPolicy.Name == "on-failure") {
|
|
| 251 |
- return nil, nil, cmd, ErrConflictRestartPolicyAndAutoRemove |
|
| 252 |
- } |
|
| 253 |
- |
|
| 254 | 250 |
config := &Config{
|
| 255 | 251 |
Hostname: hostname, |
| 256 | 252 |
Domainname: domainname, |