Merge pull request #10547 from duglin/Issue10214

Pretty the help text
This commit is contained in:
Jessie Frazelle 2015-02-04 11:31:18 -08:00
Родитель 8a91926cd9 2203b37733
Коммит a271eaeba2
9 изменённых файлов: 250 добавлений и 145 удалений

Просмотреть файл

@ -79,13 +79,13 @@ func (cli *DockerCli) CmdHelp(args ...string) error {
func (cli *DockerCli) CmdBuild(args ...string) error { func (cli *DockerCli) CmdBuild(args ...string) error {
cmd := cli.Subcmd("build", "PATH | URL | -", "Build a new image from the source code at PATH", true) cmd := cli.Subcmd("build", "PATH | URL | -", "Build a new image from the source code at PATH", true)
tag := cmd.String([]string{"t", "-tag"}, "", "Repository name (and optionally a tag) to be applied to the resulting image in case of success") tag := cmd.String([]string{"t", "-tag"}, "", "Repository name (and optionally a tag) for the image")
suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers") suppressOutput := cmd.Bool([]string{"q", "-quiet"}, false, "Suppress the verbose output generated by the containers")
noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image") noCache := cmd.Bool([]string{"#no-cache", "-no-cache"}, false, "Do not use cache when building the image")
rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build") rm := cmd.Bool([]string{"#rm", "-rm"}, true, "Remove intermediate containers after a successful build")
forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers, even after unsuccessful builds") forceRm := cmd.Bool([]string{"-force-rm"}, false, "Always remove intermediate containers")
pull := cmd.Bool([]string{"-pull"}, false, "Always attempt to pull a newer version of the image") pull := cmd.Bool([]string{"-pull"}, false, "Always attempt to pull a newer version of the image")
dockerfileName := cmd.String([]string{"f", "-file"}, "", "Name of the Dockerfile(Default is 'Dockerfile' at context root)") dockerfileName := cmd.String([]string{"f", "-file"}, "", "Name of the Dockerfile(Default is 'Dockerfile')")
cmd.Require(flag.Exact, 1) cmd.Require(flag.Exact, 1)
@ -284,7 +284,7 @@ func (cli *DockerCli) CmdBuild(args ...string) error {
// 'docker login': login / register a user to registry service. // 'docker login': login / register a user to registry service.
func (cli *DockerCli) CmdLogin(args ...string) error { func (cli *DockerCli) CmdLogin(args ...string) error {
cmd := cli.Subcmd("login", "[SERVER]", "Register or log in to a Docker registry server, if no server is specified \""+registry.IndexServerAddress()+"\" is the default.", true) cmd := cli.Subcmd("login", "[SERVER]", "Register or log in to a Docker registry server, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true)
cmd.Require(flag.Max, 1) cmd.Require(flag.Max, 1)
var username, password, email string var username, password, email string
@ -400,7 +400,7 @@ func (cli *DockerCli) CmdLogin(args ...string) error {
// log out from a Docker registry // log out from a Docker registry
func (cli *DockerCli) CmdLogout(args ...string) error { func (cli *DockerCli) CmdLogout(args ...string) error {
cmd := cli.Subcmd("logout", "[SERVER]", "Log out from a Docker registry, if no server is specified \""+registry.IndexServerAddress()+"\" is the default.", true) cmd := cli.Subcmd("logout", "[SERVER]", "Log out from a Docker registry, if no server is\nspecified \""+registry.IndexServerAddress()+"\" is the default.", true)
cmd.Require(flag.Max, 1) cmd.Require(flag.Max, 1)
utils.ParseFlags(cmd, args, false) utils.ParseFlags(cmd, args, false)
@ -601,8 +601,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
} }
func (cli *DockerCli) CmdStop(args ...string) error { func (cli *DockerCli) CmdStop(args ...string) error {
cmd := cli.Subcmd("stop", "CONTAINER [CONTAINER...]", "Stop a running container by sending SIGTERM and then SIGKILL after a grace period", true) cmd := cli.Subcmd("stop", "CONTAINER [CONTAINER...]", "Stop a running container by sending SIGTERM and then SIGKILL after a\ngrace period", true)
nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to wait for the container to stop before killing it. Default is 10 seconds.") nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing it.")
cmd.Require(flag.Min, 1) cmd.Require(flag.Min, 1)
utils.ParseFlags(cmd, args, true) utils.ParseFlags(cmd, args, true)
@ -625,7 +625,7 @@ func (cli *DockerCli) CmdStop(args ...string) error {
func (cli *DockerCli) CmdRestart(args ...string) error { func (cli *DockerCli) CmdRestart(args ...string) error {
cmd := cli.Subcmd("restart", "CONTAINER [CONTAINER...]", "Restart a running container", true) cmd := cli.Subcmd("restart", "CONTAINER [CONTAINER...]", "Restart a running container", true)
nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default is 10 seconds.") nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Seconds to wait for stop before killing the container.")
cmd.Require(flag.Min, 1) cmd.Require(flag.Min, 1)
utils.ParseFlags(cmd, args, true) utils.ParseFlags(cmd, args, true)
@ -678,7 +678,7 @@ func (cli *DockerCli) CmdStart(args ...string) error {
tty bool tty bool
cmd = cli.Subcmd("start", "CONTAINER [CONTAINER...]", "Restart a stopped container", true) cmd = cli.Subcmd("start", "CONTAINER [CONTAINER...]", "Restart a stopped container", true)
attach = cmd.Bool([]string{"a", "-attach"}, false, "Attach container's STDOUT and STDERR and forward all signals to the process") attach = cmd.Bool([]string{"a", "-attach"}, false, "Attach STDOUT/STDERR and forward signals")
openStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Attach container's STDIN") openStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Attach container's STDIN")
) )
@ -947,7 +947,7 @@ func (cli *DockerCli) CmdTop(args ...string) error {
} }
func (cli *DockerCli) CmdPort(args ...string) error { func (cli *DockerCli) CmdPort(args ...string) error {
cmd := cli.Subcmd("port", "CONTAINER [PRIVATE_PORT[/PROTO]]", "List port mappings for the CONTAINER, or lookup the public-facing port that is NAT-ed to the PRIVATE_PORT", true) cmd := cli.Subcmd("port", "CONTAINER [PRIVATE_PORT[/PROTO]]", "List port mappings for the CONTAINER, or lookup the public-facing port that\nis NAT-ed to the PRIVATE_PORT", true)
cmd.Require(flag.Min, 1) cmd.Require(flag.Min, 1)
utils.ParseFlags(cmd, args, true) utils.ParseFlags(cmd, args, true)
@ -1094,7 +1094,7 @@ func (cli *DockerCli) CmdHistory(args ...string) error {
func (cli *DockerCli) CmdRm(args ...string) error { func (cli *DockerCli) CmdRm(args ...string) error {
cmd := cli.Subcmd("rm", "CONTAINER [CONTAINER...]", "Remove one or more containers", true) cmd := cli.Subcmd("rm", "CONTAINER [CONTAINER...]", "Remove one or more containers", true)
v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container") v := cmd.Bool([]string{"v", "-volumes"}, false, "Remove the volumes associated with the container")
link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link and not the underlying container") link := cmd.Bool([]string{"l", "#link", "-link"}, false, "Remove the specified link")
force := cmd.Bool([]string{"f", "-force"}, false, "Force the removal of a running container (uses SIGKILL)") force := cmd.Bool([]string{"f", "-force"}, false, "Force the removal of a running container (uses SIGKILL)")
cmd.Require(flag.Min, 1) cmd.Require(flag.Min, 1)
@ -1146,7 +1146,7 @@ func (cli *DockerCli) CmdKill(args ...string) error {
} }
func (cli *DockerCli) CmdImport(args ...string) error { func (cli *DockerCli) CmdImport(args ...string) error {
cmd := cli.Subcmd("import", "URL|- [REPOSITORY[:TAG]]", "Create an empty filesystem image and import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally tag it.", true) cmd := cli.Subcmd("import", "URL|- [REPOSITORY[:TAG]]", "Create an empty filesystem image and import the contents of the\ntarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then\noptionally tag it.", true)
cmd.Require(flag.Min, 1) cmd.Require(flag.Min, 1)
utils.ParseFlags(cmd, args, true) utils.ParseFlags(cmd, args, true)
@ -1309,7 +1309,7 @@ func (cli *DockerCli) CmdPull(args ...string) error {
func (cli *DockerCli) CmdImages(args ...string) error { func (cli *DockerCli) CmdImages(args ...string) error {
cmd := cli.Subcmd("images", "[REPOSITORY]", "List images", true) cmd := cli.Subcmd("images", "[REPOSITORY]", "List images", true)
quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs") quiet := cmd.Bool([]string{"q", "-quiet"}, false, "Only show numeric IDs")
all := cmd.Bool([]string{"a", "-all"}, false, "Show all images (by default filter out the intermediate image layers)") all := cmd.Bool([]string{"a", "-all"}, false, "Show all images (default hides intermediate images)")
noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") noTrunc := cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
// FIXME: --viz and --tree are deprecated. Remove them in a future version. // FIXME: --viz and --tree are deprecated. Remove them in a future version.
flViz := cmd.Bool([]string{"#v", "#viz", "#-viz"}, false, "Output graph in graphviz format") flViz := cmd.Bool([]string{"#v", "#viz", "#-viz"}, false, "Output graph in graphviz format")
@ -1542,12 +1542,12 @@ func (cli *DockerCli) CmdPs(args ...string) error {
cmd = cli.Subcmd("ps", "", "List containers", true) cmd = cli.Subcmd("ps", "", "List containers", true)
quiet = cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs") quiet = cmd.Bool([]string{"q", "-quiet"}, false, "Only display numeric IDs")
size = cmd.Bool([]string{"s", "-size"}, false, "Display total file sizes") size = cmd.Bool([]string{"s", "-size"}, false, "Display total file sizes")
all = cmd.Bool([]string{"a", "-all"}, false, "Show all containers. Only running containers are shown by default.") all = cmd.Bool([]string{"a", "-all"}, false, "Show all containers (default shows just running)")
noTrunc = cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output") noTrunc = cmd.Bool([]string{"#notrunc", "-no-trunc"}, false, "Don't truncate output")
nLatest = cmd.Bool([]string{"l", "-latest"}, false, "Show only the latest created container, include non-running ones.") nLatest = cmd.Bool([]string{"l", "-latest"}, false, "Show the latest created container, include non-running.")
since = cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show only containers created since Id or Name, include non-running ones.") since = cmd.String([]string{"#sinceId", "#-since-id", "-since"}, "", "Show created since Id or Name, include non-running.")
before = cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name, include non-running ones.") before = cmd.String([]string{"#beforeId", "#-before-id", "-before"}, "", "Show only container created before Id or Name.")
last = cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running ones.") last = cmd.Int([]string{"n"}, -1, "Show n last created containers, include non-running.")
flFilter = opts.NewListOpts(nil) flFilter = opts.NewListOpts(nil)
) )
cmd.Require(flag.Exact, 0) cmd.Require(flag.Exact, 0)
@ -1847,7 +1847,7 @@ func (cli *DockerCli) CmdLogs(args ...string) error {
cmd = cli.Subcmd("logs", "CONTAINER", "Fetch the logs of a container", true) cmd = cli.Subcmd("logs", "CONTAINER", "Fetch the logs of a container", true)
follow = cmd.Bool([]string{"f", "-follow"}, false, "Follow log output") follow = cmd.Bool([]string{"f", "-follow"}, false, "Follow log output")
times = cmd.Bool([]string{"t", "-timestamps"}, false, "Show timestamps") times = cmd.Bool([]string{"t", "-timestamps"}, false, "Show timestamps")
tail = cmd.String([]string{"-tail"}, "all", "Output the specified number of lines at the end of logs (defaults to all logs)") tail = cmd.String([]string{"-tail"}, "all", "Number of lines to show from the end of the logs")
) )
cmd.Require(flag.Exact, 1) cmd.Require(flag.Exact, 1)
@ -1885,7 +1885,7 @@ func (cli *DockerCli) CmdAttach(args ...string) error {
var ( var (
cmd = cli.Subcmd("attach", "CONTAINER", "Attach to a running container", true) cmd = cli.Subcmd("attach", "CONTAINER", "Attach to a running container", true)
noStdin = cmd.Bool([]string{"#nostdin", "-no-stdin"}, false, "Do not attach STDIN") noStdin = cmd.Bool([]string{"#nostdin", "-no-stdin"}, false, "Do not attach STDIN")
proxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy all received signals to the process (non-TTY mode only). SIGCHLD, SIGKILL, and SIGSTOP are not proxied.") proxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy all received signals to the process")
) )
cmd.Require(flag.Exact, 1) cmd.Require(flag.Exact, 1)
@ -2202,9 +2202,9 @@ func (cli *DockerCli) CmdRun(args ...string) error {
// These are flags not stored in Config/HostConfig // These are flags not stored in Config/HostConfig
var ( var (
flAutoRemove = cmd.Bool([]string{"#rm", "-rm"}, false, "Automatically remove the container when it exits (incompatible with -d)") flAutoRemove = cmd.Bool([]string{"#rm", "-rm"}, false, "Automatically remove the container when it exits")
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, "Run container in background and print container ID")
flSigProxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied.") flSigProxy = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxy received signals to the process")
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
@ -2728,7 +2728,7 @@ func (cli *DockerCli) CmdStats(args ...string) error {
if len(errs) > 0 { if len(errs) > 0 {
return fmt.Errorf("%s", strings.Join(errs, ", ")) return fmt.Errorf("%s", strings.Join(errs, ", "))
} }
for _ = range time.Tick(500 * time.Millisecond) { for range time.Tick(500 * time.Millisecond) {
printHeader() printHeader()
toRemove := []int{} toRemove := []int{}
for i, s := range cStats { for i, s := range cStats {

Просмотреть файл

@ -50,27 +50,27 @@ type Config struct {
// from the command-line. // from the command-line.
func (config *Config) InstallFlags() { func (config *Config) InstallFlags() {
flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file") flag.StringVar(&config.Pidfile, []string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
flag.StringVar(&config.Root, []string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime") flag.StringVar(&config.Root, []string{"g", "-graph"}, "/var/lib/docker", "Root of the Docker runtime")
flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run") flag.BoolVar(&config.AutoRestart, []string{"#r", "#-restart"}, true, "--restart on the daemon has been deprecated in favor of --restart policies on docker run")
flag.BoolVar(&config.EnableIptables, []string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules") flag.BoolVar(&config.EnableIptables, []string{"#iptables", "-iptables"}, true, "Enable addition of iptables rules")
flag.BoolVar(&config.EnableIpForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward and IPv6 forwarding if --fixed-cidr-v6 is defined. IPv6 forwarding may interfere with your existing IPv6 configuration when using Router Advertisement.") flag.BoolVar(&config.EnableIpForward, []string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
flag.BoolVar(&config.EnableIpMasq, []string{"-ip-masq"}, true, "Enable IP masquerading for bridge's IP range") flag.BoolVar(&config.EnableIpMasq, []string{"-ip-masq"}, true, "Enable IP masquerading")
flag.BoolVar(&config.EnableIPv6, []string{"-ipv6"}, false, "Enable IPv6 networking") flag.BoolVar(&config.EnableIPv6, []string{"-ipv6"}, false, "Enable IPv6 networking")
flag.StringVar(&config.BridgeIP, []string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b") flag.StringVar(&config.BridgeIP, []string{"#bip", "-bip"}, "", "Specify network bridge IP")
flag.StringVar(&config.BridgeIface, []string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking") flag.StringVar(&config.BridgeIface, []string{"b", "-bridge"}, "", "Attach containers to a network bridge")
flag.StringVar(&config.FixedCIDR, []string{"-fixed-cidr"}, "", "IPv4 subnet for fixed IPs (e.g. 10.20.0.0/16)\nthis subnet must be nested in the bridge subnet (which is defined by -b or --bip)") flag.StringVar(&config.FixedCIDR, []string{"-fixed-cidr"}, "", "IPv4 subnet for fixed IPs")
flag.StringVar(&config.FixedCIDRv6, []string{"-fixed-cidr-v6"}, "", "IPv6 subnet for fixed IPs (e.g.: 2001:a02b/48)") flag.StringVar(&config.FixedCIDRv6, []string{"-fixed-cidr-v6"}, "", "IPv6 subnet for fixed IPs")
flag.BoolVar(&config.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Allow unrestricted inter-container and Docker daemon host communication") flag.BoolVar(&config.InterContainerCommunication, []string{"#icc", "-icc"}, true, "Enable inter-container communication")
flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Force the Docker runtime to use a specific storage driver") flag.StringVar(&config.GraphDriver, []string{"s", "-storage-driver"}, "", "Storage driver to use")
flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, "native", "Force the Docker runtime to use a specific exec driver") flag.StringVar(&config.ExecDriver, []string{"e", "-exec-driver"}, "native", "Exec driver to use")
flag.BoolVar(&config.EnableSelinuxSupport, []string{"-selinux-enabled"}, false, "Enable selinux support. SELinux does not presently support the BTRFS storage driver") flag.BoolVar(&config.EnableSelinuxSupport, []string{"-selinux-enabled"}, false, "Enable selinux support")
flag.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, "Set the containers network MTU\nif no value is provided: default to the default route MTU or 1500 if no default route is available") flag.IntVar(&config.Mtu, []string{"#mtu", "-mtu"}, 0, "Set the containers network MTU")
opts.IPVar(&config.DefaultIp, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP address to use when binding container ports") opts.IPVar(&config.DefaultIp, []string{"#ip", "-ip"}, "0.0.0.0", "Default IP when binding container ports")
opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options") opts.ListVar(&config.GraphOptions, []string{"-storage-opt"}, "Set storage driver options")
// FIXME: why the inconsistency between "hosts" and "sockets"? // FIXME: why the inconsistency between "hosts" and "sockets"?
opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "Force Docker to use specific DNS servers") opts.IPListVar(&config.Dns, []string{"#dns", "-dns"}, "DNS server to use")
opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains") opts.DnsSearchListVar(&config.DnsSearch, []string{"-dns-search"}, "DNS search domains to use")
opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=value labels to the daemon (displayed in `docker info`)") opts.LabelListVar(&config.Labels, []string{"-label"}, "Set key=value labels to the daemon")
} }
func getDefaultNetworkMtu() int { func getDefaultNetworkMtu() int {

Просмотреть файл

@ -40,12 +40,12 @@ var (
flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit") flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode") flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode") flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group") flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group for the unix socket")
flLogLevel = flag.String([]string{"l", "-log-level"}, "info", "Set the logging level (debug, info, warn, error, fatal)") flLogLevel = flag.String([]string{"l", "-log-level"}, "info", "Set the logging level")
flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API") flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by --tlsverify flag") flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by --tlsverify flag")
flHelp = flag.Bool([]string{"h", "-help"}, false, "Print usage") flHelp = flag.Bool([]string{"h", "-help"}, false, "Print usage")
flTlsVerify = flag.Bool([]string{"-tlsverify"}, dockerTlsVerify, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)") flTlsVerify = flag.Bool([]string{"-tlsverify"}, dockerTlsVerify, "Use TLS and verify the remote")
// these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs // these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
flTrustKey *string flTrustKey *string
@ -70,10 +70,10 @@ func init() {
// TODO use flag flag.String([]string{"i", "-identity"}, "", "Path to libtrust key file") // TODO use flag flag.String([]string{"i", "-identity"}, "", "Path to libtrust key file")
flTrustKey = &placeholderTrustKey flTrustKey = &placeholderTrustKey
flCa = flag.String([]string{"-tlscacert"}, filepath.Join(dockerCertPath, defaultCaFile), "Trust only remotes providing a certificate signed by the CA given here") flCa = flag.String([]string{"-tlscacert"}, filepath.Join(dockerCertPath, defaultCaFile), "Trust certs signed only by this CA")
flCert = flag.String([]string{"-tlscert"}, filepath.Join(dockerCertPath, defaultCertFile), "Path to TLS certificate file") flCert = flag.String([]string{"-tlscert"}, filepath.Join(dockerCertPath, defaultCertFile), "Path to TLS certificate file")
flKey = flag.String([]string{"-tlskey"}, filepath.Join(dockerCertPath, defaultKeyFile), "Path to TLS key file") flKey = flag.String([]string{"-tlskey"}, filepath.Join(dockerCertPath, defaultKeyFile), "Path to TLS key file")
opts.HostListVar(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode or connect to in client mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.") opts.HostListVar(&flHosts, []string{"H", "-host"}, "Daemon socket(s) to use or connect to")
flag.Usage = func() { flag.Usage = func() {
fmt.Fprint(os.Stdout, "Usage: docker [OPTIONS] COMMAND [arg...]\n\nA self-sufficient runtime for linux containers.\n\nOptions:\n") fmt.Fprint(os.Stdout, "Usage: docker [OPTIONS] COMMAND [arg...]\n\nA self-sufficient runtime for linux containers.\n\nOptions:\n")
@ -116,7 +116,7 @@ func init() {
{"save", "Save an image to a tar archive"}, {"save", "Save an image to a tar archive"},
{"search", "Search for an image on the Docker Hub"}, {"search", "Search for an image on the Docker Hub"},
{"start", "Start a stopped container"}, {"start", "Start a stopped container"},
{"stats", "Display a live stream of one or more containers' resource usage statistics"}, {"stats", "Display a stream of a containers' resource usage statistics"},
{"stop", "Stop a running container"}, {"stop", "Stop a running container"},
{"tag", "Tag an image into a repository"}, {"tag", "Tag an image into a repository"},
{"top", "Lookup the running processes of a container"}, {"top", "Lookup the running processes of a container"},

Просмотреть файл

@ -70,42 +70,38 @@ expect an integer, and they can only be specified once.
Options: Options:
--api-enable-cors=false Enable CORS headers in the remote API --api-enable-cors=false Enable CORS headers in the remote API
-b, --bridge="" Attach containers to a pre-existing network bridge -b, --bridge="" Attach containers to a network bridge
use 'none' to disable container networking --bip="" Specify network bridge IP
--bip="" Use this CIDR notation address for the network bridge's IP, not compatible with -b
-D, --debug=false Enable debug mode -D, --debug=false Enable debug mode
-d, --daemon=false Enable daemon mode -d, --daemon=false Enable daemon mode
--dns=[] Force Docker to use specific DNS servers --dns=[] DNS server to use
--dns-search=[] Force Docker to use specific DNS search domains --dns-search=[] DNS search domains to use
-e, --exec-driver="native" Force the Docker runtime to use a specific exec driver -e, --exec-driver="native" Exec driver to use
--fixed-cidr="" IPv4 subnet for fixed IPs (e.g.: 10.20.0.0/16) --fixed-cidr="" IPv4 subnet for fixed IPs
this subnet must be nested in the bridge subnet (which is defined by -b or --bip) --fixed-cidr-v6="" IPv6 subnet for fixed IPs
--fixed-cidr-v6="" IPv6 subnet for global IPs (e.g.: 2a00:1450::/64) -G, --group="docker" Group for the unix socket
-G, --group="docker" Group to assign the unix socket specified by -H when running in daemon mode -g, --graph="/var/lib/docker" Root of the Docker runtime
use '' (the empty string) to disable setting of a group -H, --host=[] Daemon socket(s) to use or connect to
-g, --graph="/var/lib/docker" Path to use as the root of the Docker runtime --icc=true Enable inter-container communication
-H, --host=[] The socket(s) to bind to in daemon mode or connect to in client mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd. --insecure-registry=[] Enable insecure registry communication
--icc=true Allow unrestricted inter-container and Docker daemon host communication --ip=0.0.0.0 Default IP when binding container ports
--insecure-registry=[] Enable insecure communication with specified registries (disables certificate verification for HTTPS and enables HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16) --ip-forward=true Enable net.ipv4.ip_forward
--ip=0.0.0.0 Default IP address to use when binding container ports --ip-masq=true Enable IP masquerading
--ip-forward=true Enable net.ipv4.ip_forward and IPv6 forwarding if --fixed-cidr-v6 is defined. IPv6 forwarding may interfere with your existing IPv6 configuration when using Router Advertisement. --iptables=true Enable addition of iptables rules
--ip-masq=true Enable IP masquerading for bridge's IP range --ipv6=false Enable IPv6 networking
--iptables=true Enable Docker's addition of iptables rules -l, --log-level="info" Set the logging level
--ipv6=false Enable Docker IPv6 support --label=[] Set key=value labels to the daemon
-l, --log-level="info" Set the logging level (debug, info, warn, error, fatal)
--label=[] Set key=value labels to the daemon (displayed in `docker info`)
--mtu=0 Set the containers network MTU --mtu=0 Set the containers network MTU
if no value is provided: default to the default route MTU or 1500 if no default route is available
-p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file -p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file
--registry-mirror=[] Specify a preferred Docker registry mirror --registry-mirror=[] Preferred Docker registry mirror
-s, --storage-driver="" Force the Docker runtime to use a specific storage driver -s, --storage-driver="" Storage driver to use
--selinux-enabled=false Enable selinux support. SELinux does not presently support the BTRFS storage driver --selinux-enabled=false Enable selinux support
--storage-opt=[] Set storage driver options --storage-opt=[] Set storage driver options
--tls=false Use TLS; implied by --tlsverify flag --tls=false Use TLS; implied by --tlsverify flag
--tlscacert="/home/sven/.docker/ca.pem" Trust only remotes providing a certificate signed by the CA given here --tlscacert="/home/sven/.docker/ca.pem" Trust certs signed only by this CA
--tlscert="/home/sven/.docker/cert.pem" Path to TLS certificate file --tlscert="/home/sven/.docker/cert.pem" Path to TLS certificate file
--tlskey="/home/sven/.docker/key.pem" Path to TLS key file --tlskey="/home/sven/.docker/key.pem" Path to TLS key file
--tlsverify=false Use TLS and verify the remote (daemon: verify client, client: verify daemon) --tlsverify=false Use TLS and verify the remote
-v, --version=false Print version information and quit -v, --version=false Print version information and quit
Options with [] may be specified multiple times. Options with [] may be specified multiple times.
@ -428,7 +424,7 @@ Docker supports softlinks for the Docker data directory
Attach to a running container Attach to a running container
--no-stdin=false Do not attach STDIN --no-stdin=false Do not attach STDIN
--sig-proxy=true Proxy all received signals to the process (non-TTY mode only). SIGCHLD, SIGKILL, and SIGSTOP are not proxied. --sig-proxy=true Proxy all received signals to the process
The `attach` command lets you view or interact with any running container's The `attach` command lets you view or interact with any running container's
primary process (`pid 1`). primary process (`pid 1`).
@ -489,12 +485,13 @@ To kill the container, use `docker kill`.
Build a new image from the source code at PATH Build a new image from the source code at PATH
--force-rm=false Always remove intermediate containers, even after unsuccessful builds -f, --file="" Name of the Dockerfile(Default is 'Dockerfile')
--force-rm=false Always remove intermediate containers
--no-cache=false Do not use cache when building the image --no-cache=false Do not use cache when building the image
--pull=false Always attempt to pull a newer version of the image --pull=false Always attempt to pull a newer version of the image
-q, --quiet=false Suppress the verbose output generated by the containers -q, --quiet=false Suppress the verbose output generated by the containers
--rm=true Remove intermediate containers after a successful build --rm=true Remove intermediate containers after a successful build
-t, --tag="" Repository name (and optionally a tag) to be applied to the resulting image in case of success -t, --tag="" Repository name (and optionally a tag) for the image
Use this command to build Docker images from a Dockerfile and a Use this command to build Docker images from a Dockerfile and a
"context". "context".
@ -734,41 +731,31 @@ Creates a new container.
--cap-drop=[] Drop Linux capabilities --cap-drop=[] Drop Linux capabilities
--cidfile="" Write the container ID to the file --cidfile="" Write the container ID to the file
--cpuset="" CPUs in which to allow execution (0-3, 0,1) --cpuset="" CPUs in which to allow execution (0-3, 0,1)
--device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) --device=[] Add a host device to the container
--dns=[] Set custom DNS servers --dns=[] Set custom DNS servers
--dns-search=[] Set custom DNS search domains (Use --dns-search=. if you don't wish to set the search domain) --dns-search=[] Set custom DNS search domains
-e, --env=[] Set environment variables -e, --env=[] Set environment variables
--entrypoint="" Overwrite the default ENTRYPOINT of the image --entrypoint="" Overwrite the default ENTRYPOINT of the image
--env-file=[] Read in a line delimited file of environment variables --env-file=[] Read in a file of environment variables
--expose=[] Expose a port or a range of ports (e.g. --expose=3300-3310) from the container without publishing it to your host --expose=[] Expose a port or a range of ports
-h, --hostname="" Container host name -h, --hostname="" Container host name
-i, --interactive=false Keep STDIN open even if not attached -i, --interactive=false Keep STDIN open even if not attached
--ipc="" Default is to create a private IPC namespace (POSIX SysV IPC) for the container --ipc="" IPC namespace to use
'container:<name|id>': reuses another container shared memory, semaphores and message queues --link=[] Add link to another container
'host': use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure. --lxc-conf=[] Add custom lxc options
--link=[] Add link to another container in the form of <name or id>:alias -m, --memory="" Memory limit
--lxc-conf=[] (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
-m, --memory="" Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
--mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33) --mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33)
--name="" Assign a name to the container --name="" Assign a name to the container
--net="bridge" Set the Network mode for the container --net="bridge" Set the Network mode for the container
'bridge': creates a new network stack for the container on the docker bridge -P, --publish-all=false Publish all exposed ports to random ports
'none': no networking for this container -p, --publish=[] Publish a container's port(s) to the host
'container:<name|id>': reuses another container network stack
'host': use the host network stack inside the container. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.
-P, --publish-all=false Publish all exposed ports to random ports on the host interfaces
-p, --publish=[] Publish a container's port, or a range of ports (e.g., `-p 3300-3310`), to the host
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
Both hostPort and containerPort can be specified as a range of ports.
When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (e.g., `-p 1234-1236:1234-1236/tcp`)
(use 'docker port' to see the actual mapping)
--privileged=false Give extended privileges to this container --privileged=false Give extended privileges to this container
--read-only=false Mount the container's root filesystem as read only --read-only=false Mount the container's root filesystem as read only
--restart="" Restart policy to apply when a container exits (no, on-failure[:max-retry], always) --restart="" Restart policy to apply when a container exits
--security-opt=[] Security Options --security-opt=[] Security Options
-t, --tty=false Allocate a pseudo-TTY -t, --tty=false Allocate a pseudo-TTY
-u, --user="" Username or UID -u, --user="" Username or UID
-v, --volume=[] Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container) -v, --volume=[] Bind mount a volume
--volumes-from=[] Mount volumes from the specified container(s) --volumes-from=[] Mount volumes from the specified container(s)
-w, --workdir="" Working directory inside the container -w, --workdir="" Working directory inside the container
@ -1043,7 +1030,7 @@ To see how the `docker:latest` image was built:
List images List images
-a, --all=false Show all images (by default filter out the intermediate image layers) -a, --all=false Show all images (default hides intermediate images)
-f, --filter=[] Provide filter values (i.e., 'dangling=true') -f, --filter=[] Provide filter values (i.e., 'dangling=true')
--no-trunc=false Don't truncate output --no-trunc=false Don't truncate output
-q, --quiet=false Only show numeric IDs -q, --quiet=false Only show numeric IDs
@ -1136,7 +1123,9 @@ NOTE: Docker will warn you if any containers exist that are using these untagged
Usage: docker import URL|- [REPOSITORY[:TAG]] Usage: docker import URL|- [REPOSITORY[:TAG]]
Create an empty filesystem image and import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally tag it. Create an empty filesystem image and import the contents of the
tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then
optionally tag it.
URLs must start with `http` and point to a single file archive (.tar, URLs must start with `http` and point to a single file archive (.tar,
.tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a root filesystem. If .tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a root filesystem. If
@ -1305,7 +1294,8 @@ Restores both images and tags.
Usage: docker login [OPTIONS] [SERVER] Usage: docker login [OPTIONS] [SERVER]
Register or log in to a Docker registry server, if no server is specified "https://index.docker.io/v1/" is the default. Register or log in to a Docker registry server, if no server is
specified "https://index.docker.io/v1/" is the default.
-e, --email="" Email -e, --email="" Email
-p, --password="" Password -p, --password="" Password
@ -1321,7 +1311,8 @@ adding the server name.
Usage: docker logout [SERVER] Usage: docker logout [SERVER]
Log out from a Docker registry, if no server is specified "https://index.docker.io/v1/" is the default. Log out from a Docker registry, if no server is
specified "https://index.docker.io/v1/" is the default.
For example: For example:
@ -1335,7 +1326,7 @@ For example:
-f, --follow=false Follow log output -f, --follow=false Follow log output
-t, --timestamps=false Show timestamps -t, --timestamps=false Show timestamps
--tail="all" Output the specified number of lines at the end of logs (defaults to all logs) --tail="all" Number of lines to show from the end of the logs
The `docker logs` command batch-retrieves logs present at the time of execution. The `docker logs` command batch-retrieves logs present at the time of execution.
@ -1370,7 +1361,8 @@ for further details.
Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]] Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]]
List port mappings for the CONTAINER, or lookup the public-facing port that is NAT-ed to the PRIVATE_PORT List port mappings for the CONTAINER, or lookup the public-facing port that is
NAT-ed to the PRIVATE_PORT
You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or
just a specific mapping: just a specific mapping:
@ -1418,17 +1410,17 @@ The `docker rename` command allows the container to be renamed to a different na
List containers List containers
-a, --all=false Show all containers. Only running containers are shown by default. -a, --all=false Show all containers (default shows just running)
--before="" Show only container created before Id or Name, include non-running ones. --before="" Show only container created before Id or Name.
-f, --filter=[] Provide filter values. Valid filters: -f, --filter=[] Provide filter values. Valid filters:
exited=<int> - containers with exit code of <int> exited=<int> - containers with exit code of <int>
status=(restarting|running|paused|exited) status=(restarting|running|paused|exited)
-l, --latest=false Show only the latest created container, include non-running ones. -l, --latest=false Show the latest created container, include non-running.
-n=-1 Show n last created containers, include non-running ones. -n=-1 Show n last created containers, include non-running .
--no-trunc=false Don't truncate output --no-trunc=false Don't truncate output
-q, --quiet=false Only display numeric IDs -q, --quiet=false Only display numeric IDs
-s, --size=false Display total file sizes -s, --size=false Display total file sizes
--since="" Show only containers created since Id or Name, include non-running ones. --since="" Show created since Id or Name, include non-running.
Running `docker ps` showing 2 linked containers. Running `docker ps` showing 2 linked containers.
@ -1510,7 +1502,7 @@ registry or to a self-hosted one.
Restart a running container Restart a running container
-t, --time=10 Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default is 10 seconds. -t, --time=10 Seconds to wait for stop before killing the container.
## rm ## rm
@ -1519,7 +1511,7 @@ registry or to a self-hosted one.
Remove one or more containers Remove one or more containers
-f, --force=false Force the removal of a running container (uses SIGKILL) -f, --force=false Force the removal of a running container (uses SIGKILL)
-l, --link=false Remove the specified link and not the underlying container -l, --link=false Remove the specified link
-v, --volumes=false Remove the volumes associated with the container -v, --volumes=false Remove the volumes associated with the container
#### Examples #### Examples
@ -1597,7 +1589,7 @@ removed before the image is removed.
--cap-drop=[] Drop Linux capabilities --cap-drop=[] Drop Linux capabilities
--cidfile="" Write the container ID to the file --cidfile="" Write the container ID to the file
--cpuset="" CPUs in which to allow execution (0-3, 0,1) --cpuset="" CPUs in which to allow execution (0-3, 0,1)
-d, --detach=false Detached mode: run the container in the background and print the new container ID -d, --detach=false Run container in background and print container ID
--device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm) --device=[] Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)
--dns=[] Set custom DNS servers --dns=[] Set custom DNS servers
--dns-search=[] Set custom DNS search domains (Use --dns-search=. if you don't wish to set the search domain) --dns-search=[] Set custom DNS search domains (Use --dns-search=. if you don't wish to set the search domain)
@ -1611,9 +1603,9 @@ removed before the image is removed.
'container:<name|id>': reuses another container shared memory, semaphores and message queues 'container:<name|id>': reuses another container shared memory, semaphores and message queues
'host': use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure. 'host': use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure.
--link=[] Add link to another container in the form of name:alias --link=[] Add link to another container in the form of name:alias
--lxc-conf=[] (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1" --lxc-conf=[] Add custom lxc options
-m, --memory="" Memory limit (format: <number><optional unit>, where unit = b, k, m or g) -m, --memory="" Memory limit
-memory-swap="" Total memory usage (memory + swap), set '-1' to disable swap (format: <number><optional unit>, where unit = b, k, m or g) -memory-swap="" Total memory (memory+swap), '-1' to disable swap
--mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33) --mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33)
--name="" Assign a name to the container --name="" Assign a name to the container
--net="bridge" Set the Network mode for the container --net="bridge" Set the Network mode for the container
@ -1631,9 +1623,9 @@ removed before the image is removed.
--privileged=false Give extended privileges to this container --privileged=false Give extended privileges to this container
--read-only=false Mount the container's root filesystem as read only --read-only=false Mount the container's root filesystem as read only
--restart="" Restart policy to apply when a container exits (no, on-failure[:max-retry], always) --restart="" Restart policy to apply when a container exits (no, on-failure[:max-retry], always)
--rm=false Automatically remove the container when it exits (incompatible with -d) --rm=false Automatically remove the container when it exits
--security-opt=[] Security Options --security-opt=[] Security Options
--sig-proxy=true Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied. --sig-proxy=true Proxy received signals to the process
-t, --tty=false Allocate a pseudo-TTY -t, --tty=false Allocate a pseudo-TTY
-u, --user="" Username or UID -u, --user="" Username or UID
-v, --volume=[] Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container) -v, --volume=[] Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container)
@ -2001,7 +1993,7 @@ more details on finding shared images from the command line.
Restart a stopped container Restart a stopped container
-a, --attach=false Attach container's STDOUT and STDERR and forward all signals to the process -a, --attach=false Attach STDOUT/STDERR and forward signals
-i, --interactive=false Attach container's STDIN -i, --interactive=false Attach container's STDIN
## stats ## stats
@ -2030,9 +2022,10 @@ containers. Stopped containers will not return any data.
Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
Stop a running container by sending SIGTERM and then SIGKILL after a grace period Stop a running container by sending SIGTERM and then SIGKILL after a
grace period
-t, --time=10 Number of seconds to wait for the container to stop before killing it. Default is 10 seconds. -t, --time=10 Seconds to wait for stop before killing it.
The main process inside the container will receive `SIGTERM`, and after a The main process inside the container will receive `SIGTERM`, and after a
grace period, `SIGKILL`. grace period, `SIGKILL`.

Просмотреть файл

@ -341,7 +341,7 @@ milliseconds.
--cap-drop: Drop Linux capabilities --cap-drop: Drop Linux capabilities
--privileged=false: Give extended privileges to this container --privileged=false: Give extended privileges to this container
--device=[]: Allows you to run devices inside the container without the --privileged flag. --device=[]: Allows you to run devices inside the container without the --privileged flag.
--lxc-conf=[]: (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1" --lxc-conf=[]: Add custom lxc options
By default, Docker containers are "unprivileged" and cannot, for By default, Docker containers are "unprivileged" and cannot, for
example, run a Docker daemon inside a Docker container. This is because example, run a Docker daemon inside a Docker container. This is because

Просмотреть файл

@ -0,0 +1,104 @@
package main
import (
"os"
"os/exec"
"runtime"
"strings"
"testing"
)
func TestMainHelpWidth(t *testing.T) {
// Make sure main help text fits within 80 chars and that
// on non-windows system we use ~ when possible (to shorten things)
var home string
if runtime.GOOS != "windows" {
home = os.Getenv("HOME")
}
helpCmd := exec.Command(dockerBinary, "help")
out, ec, err := runCommandWithOutput(helpCmd)
if err != nil || ec != 0 {
t.Fatalf("docker help should have worked\nout:%s\nec:%d", out, ec)
}
lines := strings.Split(out, "\n")
for _, line := range lines {
if len(line) > 80 {
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
}
if home != "" && strings.Contains(line, home) {
t.Fatalf("Line should use ~ instead of %q:\n%s", home, line)
}
}
logDone("help - verify main width")
}
func TestCmdHelpWidth(t *testing.T) {
// Make sure main help text fits within 80 chars and that
// on non-windows system we use ~ when possible (to shorten things)
var home string
if runtime.GOOS != "windows" {
home = os.Getenv("HOME")
}
for _, command := range []string{
"attach",
"build",
"commit",
"cp",
"create",
"diff",
"events",
"exec",
"export",
"history",
"images",
"import",
"info",
"inspect",
"kill",
"load",
"login",
"logout",
"logs",
"port",
"pause",
"ps",
"pull",
"push",
"rename",
"restart",
"rm",
"rmi",
"run",
"save",
"search",
"start",
"stats",
"stop",
"tag",
"top",
"unpause",
"version",
"wait",
} {
helpCmd := exec.Command(dockerBinary, command, "--help")
out, ec, err := runCommandWithOutput(helpCmd)
if err != nil || ec != 0 {
t.Fatalf("docker help should have worked\nout:%s\nec:%d", out, ec)
}
lines := strings.Split(out, "\n")
for _, line := range lines {
if len(line) > 80 {
t.Fatalf("Help for %q is too long(%d chars):\n%s", command, len(line), line)
}
if home != "" && strings.Contains(line, home) {
t.Fatalf("Help for %q should use ~ instead of %q on:\n%s", command, home, line)
}
}
}
logDone("help - cmd widths")
}

Просмотреть файл

@ -86,6 +86,7 @@ import (
"fmt" "fmt"
"io" "io"
"os" "os"
"runtime"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@ -503,6 +504,10 @@ func Set(name, value string) error {
// otherwise, the default values of all defined flags in the set. // otherwise, the default values of all defined flags in the set.
func (f *FlagSet) PrintDefaults() { func (f *FlagSet) PrintDefaults() {
writer := tabwriter.NewWriter(f.Out(), 20, 1, 3, ' ', 0) writer := tabwriter.NewWriter(f.Out(), 20, 1, 3, ' ', 0)
var home string
if runtime.GOOS != "windows" {
home = os.Getenv("HOME")
}
f.VisitAll(func(flag *Flag) { f.VisitAll(func(flag *Flag) {
format := " -%s=%s" format := " -%s=%s"
if _, ok := flag.Value.(*stringValue); ok { if _, ok := flag.Value.(*stringValue); ok {
@ -516,7 +521,13 @@ func (f *FlagSet) PrintDefaults() {
} }
} }
if len(names) > 0 { if len(names) > 0 {
fmt.Fprintf(writer, format, strings.Join(names, ", -"), flag.DefValue) val := flag.DefValue
if home != "" && strings.HasPrefix(val, home) {
val = "~" + val[len(home):]
}
fmt.Fprintf(writer, format, strings.Join(names, ", -"), val)
for i, line := range strings.Split(flag.Usage, "\n") { for i, line := range strings.Split(flag.Usage, "\n") {
if i != 0 { if i != 0 {
line = " " + line line = " " + line

Просмотреть файл

@ -48,9 +48,9 @@ func IndexServerName() string {
// the current process. // the current process.
func (options *Options) InstallFlags() { func (options *Options) InstallFlags() {
options.Mirrors = opts.NewListOpts(ValidateMirror) options.Mirrors = opts.NewListOpts(ValidateMirror)
flag.Var(&options.Mirrors, []string{"-registry-mirror"}, "Specify a preferred Docker registry mirror") flag.Var(&options.Mirrors, []string{"-registry-mirror"}, "Preferred Docker registry mirror")
options.InsecureRegistries = opts.NewListOpts(ValidateIndexName) options.InsecureRegistries = opts.NewListOpts(ValidateIndexName)
flag.Var(&options.InsecureRegistries, []string{"-insecure-registry"}, "Enable insecure communication with specified registries (no certificate verification for HTTPS and enable HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16)") flag.Var(&options.InsecureRegistries, []string{"-insecure-registry"}, "Enable insecure registry communication")
} }
type netIPNet net.IPNet type netIPNet net.IPNet

Просмотреть файл

@ -46,42 +46,39 @@ func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSe
flNetwork = cmd.Bool([]string{"#n", "#-networking"}, true, "Enable networking for this container") flNetwork = cmd.Bool([]string{"#n", "#-networking"}, true, "Enable networking for this container")
flPrivileged = cmd.Bool([]string{"#privileged", "-privileged"}, false, "Give extended privileges to this container") flPrivileged = cmd.Bool([]string{"#privileged", "-privileged"}, false, "Give extended privileges to this container")
flPidMode = cmd.String([]string{"-pid"}, "", "Default is to create a private PID namespace for the container\n'host': use the host PID namespace inside the container. Note: the host mode gives the container full access to processes on the system and is therefore considered insecure.") flPidMode = cmd.String([]string{"-pid"}, "", "PID namespace to use")
flPublishAll = cmd.Bool([]string{"P", "-publish-all"}, false, "Publish all exposed ports to random ports on the host interfaces") flPublishAll = cmd.Bool([]string{"P", "-publish-all"}, false, "Publish all exposed ports to random ports")
flStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached") flStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
flTty = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY") flTty = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY")
flContainerIDFile = cmd.String([]string{"#cidfile", "-cidfile"}, "", "Write the container ID to the file") flContainerIDFile = cmd.String([]string{"#cidfile", "-cidfile"}, "", "Write the container ID to the file")
flEntrypoint = cmd.String([]string{"#entrypoint", "-entrypoint"}, "", "Overwrite the default ENTRYPOINT of the image") flEntrypoint = cmd.String([]string{"#entrypoint", "-entrypoint"}, "", "Overwrite the default ENTRYPOINT of the image")
flHostname = cmd.String([]string{"h", "-hostname"}, "", "Container host name") flHostname = cmd.String([]string{"h", "-hostname"}, "", "Container host name")
flMemoryString = cmd.String([]string{"m", "-memory"}, "", "Memory limit (format: <number><optional unit>, where unit = b, k, m or g)") flMemoryString = cmd.String([]string{"m", "-memory"}, "", "Memory limit")
flMemorySwap = cmd.String([]string{"-memory-swap"}, "", "Total memory usage (memory + swap), set '-1' to disable swap (format: <number><optional unit>, where unit = b, k, m or g)") flMemorySwap = cmd.String([]string{"-memory-swap"}, "", "Total memory (memory + swap), '-1' to disable swap")
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)")
flCpuset = cmd.String([]string{"-cpuset"}, "", "CPUs in which to allow execution (0-3, 0,1)") flCpuset = cmd.String([]string{"-cpuset"}, "", "CPUs in which to allow execution (0-3, 0,1)")
flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container\n'bridge': creates a new network stack for the container on the docker bridge\n'none': no networking for this container\n'container:<name|id>': reuses another container network stack\n'host': use the host network stack inside the container. Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.") flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container")
flMacAddress = cmd.String([]string{"-mac-address"}, "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)") flMacAddress = cmd.String([]string{"-mac-address"}, "", "Container MAC address (e.g. 92:d0:c6:0a:29:33)")
flIpcMode = cmd.String([]string{"-ipc"}, "", "Default is to create a private IPC namespace (POSIX SysV IPC) for the container\n'container:<name|id>': reuses another container shared memory, semaphores and message queues\n'host': use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure.") flIpcMode = cmd.String([]string{"-ipc"}, "", "IPC namespace to use")
flRestartPolicy = cmd.String([]string{"-restart"}, "", "Restart policy to apply when a container exits (no, on-failure[:max-retry], always)") flRestartPolicy = cmd.String([]string{"-restart"}, "", "Restart policy to apply when a container exits")
flReadonlyRootfs = cmd.Bool([]string{"-read-only"}, false, "Mount the container's root filesystem as read only") flReadonlyRootfs = cmd.Bool([]string{"-read-only"}, false, "Mount the container's root filesystem as read only")
) )
cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR.") cmd.Var(&flAttach, []string{"a", "-attach"}, "Attach to STDIN, STDOUT or STDERR.")
cmd.Var(&flVolumes, []string{"v", "-volume"}, "Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container)") cmd.Var(&flVolumes, []string{"v", "-volume"}, "Bind mount a volume")
cmd.Var(&flLinks, []string{"#link", "-link"}, "Add link to another container in the form of <name|id>:alias") cmd.Var(&flLinks, []string{"#link", "-link"}, "Add link to another container")
cmd.Var(&flDevices, []string{"-device"}, "Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)") cmd.Var(&flDevices, []string{"-device"}, "Add a host device to the container")
cmd.Var(&flEnv, []string{"e", "-env"}, "Set environment variables") cmd.Var(&flEnv, []string{"e", "-env"}, "Set environment variables")
cmd.Var(&flEnvFile, []string{"-env-file"}, "Read in a line delimited file of environment variables") cmd.Var(&flEnvFile, []string{"-env-file"}, "Read in a file of environment variables")
cmd.Var(&flPublish, []string{"p", "-publish"}, "Publish a container's port(s) to the host")
cmd.Var(&flPublish, []string{"p", "-publish"}, fmt.Sprintf("Publish a container's port to the host\nformat: %s\n(use 'docker port' to see the actual mapping)", nat.PortSpecTemplateFormat)) cmd.Var(&flExpose, []string{"#expose", "-expose"}, "Expose a port or a range of ports")
cmd.Var(&flExpose, []string{"#expose", "-expose"}, "Expose a port or a range of ports (e.g. --expose=3300-3310) from the container without publishing it to your host")
cmd.Var(&flDns, []string{"#dns", "-dns"}, "Set custom DNS servers") cmd.Var(&flDns, []string{"#dns", "-dns"}, "Set custom DNS servers")
cmd.Var(&flDnsSearch, []string{"-dns-search"}, "Set custom DNS search domains (Use --dns-search=. if you don't wish to set the search domain)") cmd.Var(&flDnsSearch, []string{"-dns-search"}, "Set custom DNS search domains")
cmd.Var(&flExtraHosts, []string{"-add-host"}, "Add a custom host-to-IP mapping (host:ip)") cmd.Var(&flExtraHosts, []string{"-add-host"}, "Add a custom host-to-IP mapping (host:ip)")
cmd.Var(&flVolumesFrom, []string{"#volumes-from", "-volumes-from"}, "Mount volumes from the specified container(s)") cmd.Var(&flVolumesFrom, []string{"#volumes-from", "-volumes-from"}, "Mount volumes from the specified container(s)")
cmd.Var(&flLxcOpts, []string{"#lxc-conf", "-lxc-conf"}, "(lxc exec-driver only) Add custom lxc options --lxc-conf=\"lxc.cgroup.cpuset.cpus = 0,1\"") cmd.Var(&flLxcOpts, []string{"#lxc-conf", "-lxc-conf"}, "Add custom lxc options")
cmd.Var(&flCapAdd, []string{"-cap-add"}, "Add Linux capabilities") cmd.Var(&flCapAdd, []string{"-cap-add"}, "Add Linux capabilities")
cmd.Var(&flCapDrop, []string{"-cap-drop"}, "Drop Linux capabilities") cmd.Var(&flCapDrop, []string{"-cap-drop"}, "Drop Linux capabilities")
cmd.Var(&flSecurityOpt, []string{"-security-opt"}, "Security Options") cmd.Var(&flSecurityOpt, []string{"-security-opt"}, "Security Options")