|
@@ -4,10 +4,8 @@ import (
|
|
"fmt"
|
|
"fmt"
|
|
"github.com/dotcloud/docker/nat"
|
|
"github.com/dotcloud/docker/nat"
|
|
"github.com/dotcloud/docker/opts"
|
|
"github.com/dotcloud/docker/opts"
|
|
- "github.com/dotcloud/docker/pkg/label"
|
|
|
|
flag "github.com/dotcloud/docker/pkg/mflag"
|
|
flag "github.com/dotcloud/docker/pkg/mflag"
|
|
"github.com/dotcloud/docker/pkg/sysinfo"
|
|
"github.com/dotcloud/docker/pkg/sysinfo"
|
|
- "github.com/dotcloud/docker/runtime/execdriver"
|
|
|
|
"github.com/dotcloud/docker/utils"
|
|
"github.com/dotcloud/docker/utils"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
"path"
|
|
"path"
|
|
@@ -34,10 +32,6 @@ func ParseSubcommand(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo)
|
|
}
|
|
}
|
|
|
|
|
|
func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Config, *HostConfig, *flag.FlagSet, error) {
|
|
func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Config, *HostConfig, *flag.FlagSet, error) {
|
|
- var (
|
|
|
|
- processLabel string
|
|
|
|
- mountLabel string
|
|
|
|
- )
|
|
|
|
var (
|
|
var (
|
|
// FIXME: use utils.ListOpts for attach and volumes?
|
|
// FIXME: use utils.ListOpts for attach and volumes?
|
|
flAttach = opts.NewListOpts(opts.ValidateAttach)
|
|
flAttach = opts.NewListOpts(opts.ValidateAttach)
|
|
@@ -67,7 +61,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|
flUser = cmd.String([]string{"u", "-user"}, "", "Username or UID")
|
|
flUser = cmd.String([]string{"u", "-user"}, "", "Username or UID")
|
|
flWorkingDir = cmd.String([]string{"w", "-workdir"}, "", "Working directory inside the container")
|
|
flWorkingDir = cmd.String([]string{"w", "-workdir"}, "", "Working directory inside the container")
|
|
flCpuShares = cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
|
flCpuShares = cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
|
- flLabelOptions = cmd.String([]string{"Z", "-label"}, "", "Options to pass to underlying labeling system")
|
|
|
|
|
|
|
|
// For documentation purpose
|
|
// For documentation purpose
|
|
_ = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxify all received signal to the process (even in non-tty mode)")
|
|
_ = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxify all received signal to the process (even in non-tty mode)")
|
|
@@ -159,15 +152,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|
entrypoint = []string{*flEntrypoint}
|
|
entrypoint = []string{*flEntrypoint}
|
|
}
|
|
}
|
|
|
|
|
|
- if !*flPrivileged {
|
|
|
|
- pLabel, mLabel, e := label.GenLabels(*flLabelOptions)
|
|
|
|
- if e != nil {
|
|
|
|
- return nil, nil, cmd, fmt.Errorf("Invalid security labels : %s", e)
|
|
|
|
- }
|
|
|
|
- processLabel = pLabel
|
|
|
|
- mountLabel = mLabel
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
lxcConf, err := parseKeyValueOpts(flLxcOpts)
|
|
lxcConf, err := parseKeyValueOpts(flLxcOpts)
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, nil, cmd, err
|
|
return nil, nil, cmd, err
|
|
@@ -222,10 +206,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|
VolumesFrom: strings.Join(flVolumesFrom.GetAll(), ","),
|
|
VolumesFrom: strings.Join(flVolumesFrom.GetAll(), ","),
|
|
Entrypoint: entrypoint,
|
|
Entrypoint: entrypoint,
|
|
WorkingDir: *flWorkingDir,
|
|
WorkingDir: *flWorkingDir,
|
|
- Context: execdriver.Context{
|
|
|
|
- "mount_label": mountLabel,
|
|
|
|
- "process_label": processLabel,
|
|
|
|
- },
|
|
|
|
}
|
|
}
|
|
|
|
|
|
driverOptions, err := parseDriverOpts(flDriverOpts)
|
|
driverOptions, err := parseDriverOpts(flDriverOpts)
|
|
@@ -233,11 +213,6 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|
return nil, nil, cmd, err
|
|
return nil, nil, cmd, err
|
|
}
|
|
}
|
|
|
|
|
|
- pluginOptions, err := parseDriverOpts(flDriverOpts)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, nil, cmd, err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
hostConfig := &HostConfig{
|
|
hostConfig := &HostConfig{
|
|
Binds: binds,
|
|
Binds: binds,
|
|
ContainerIDFile: *flContainerIDFile,
|
|
ContainerIDFile: *flContainerIDFile,
|
|
@@ -289,20 +264,3 @@ func parseKeyValueOpts(opts opts.ListOpts) ([]utils.KeyValuePair, error) {
|
|
}
|
|
}
|
|
return out, nil
|
|
return out, nil
|
|
}
|
|
}
|
|
-
|
|
|
|
-// options will come in the format of name.type=value
|
|
|
|
-func parseDriverOpts(opts opts.ListOpts) (map[string][]string, error) {
|
|
|
|
- out := make(map[string][]string, len(opts.GetAll()))
|
|
|
|
- for _, o := range opts.GetAll() {
|
|
|
|
- parts := strings.SplitN(o, ".", 2)
|
|
|
|
- if len(parts) < 2 {
|
|
|
|
- return nil, fmt.Errorf("invalid opt format %s", o)
|
|
|
|
- }
|
|
|
|
- values, exists := out[parts[0]]
|
|
|
|
- if !exists {
|
|
|
|
- values = []string{}
|
|
|
|
- }
|
|
|
|
- out[parts[0]] = append(values, parts[1])
|
|
|
|
- }
|
|
|
|
- return out, nil
|
|
|
|
-}
|
|
|