diff --git a/runconfig/parse.go b/runconfig/parse.go index f27adc2cae..5a588c0344 100644 --- a/runconfig/parse.go +++ b/runconfig/parse.go @@ -17,6 +17,7 @@ var ( ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.") ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d") ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d") + ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and --net") ) //FIXME Only used in tests @@ -101,6 +102,10 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf return nil, nil, cmd, ErrConflictDetachAutoRemove } + if *flNetMode != "bridge" && *flHostname != "" { + return nil, nil, cmd, ErrConflictNetworkHostname + } + // If neither -d or -a are set, attach to everything by default if flAttach.Len() == 0 && !*flDetach { if !*flDetach {