| ... | ... |
@@ -43,11 +43,11 @@ func main() {
|
| 43 | 43 |
flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
|
| 44 | 44 |
flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
|
| 45 | 45 |
flAutoRestart = flag.Bool([]string{"r", "-restart"}, true, "Restart previously running containers")
|
| 46 |
- bridgeName = flag.String([]string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge; use 'none' to disable container networking")
|
|
| 46 |
+ bridgeName = flag.String([]string{"b", "-bridge"}, "", "Attach containers to a pre-existing network bridge\nuse 'none' to disable container networking")
|
|
| 47 | 47 |
bridgeIp = flag.String([]string{"#bip", "-bip"}, "", "Use this CIDR notation address for the network bridge's IP, not compatible with -b")
|
| 48 | 48 |
pidfile = flag.String([]string{"p", "-pidfile"}, "/var/run/docker.pid", "Path to use for daemon PID file")
|
| 49 | 49 |
flRoot = flag.String([]string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the docker runtime")
|
| 50 |
- flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode; use '' (the empty string) to disable setting of a group")
|
|
| 50 |
+ 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")
|
|
| 51 | 51 |
flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
|
| 52 | 52 |
flDns = opts.NewListOpts(opts.ValidateIp4Address) |
| 53 | 53 |
flDnsSearch = opts.NewListOpts(opts.ValidateDomain) |
| ... | ... |
@@ -58,7 +58,7 @@ func main() {
|
| 58 | 58 |
flGraphDriver = flag.String([]string{"s", "-storage-driver"}, "", "Force the docker runtime to use a specific storage driver")
|
| 59 | 59 |
flExecDriver = flag.String([]string{"e", "-exec-driver"}, "native", "Force the docker runtime to use a specific exec driver")
|
| 60 | 60 |
flHosts = opts.NewListOpts(api.ValidateHost) |
| 61 |
- flMtu = flag.Int([]string{"#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")
|
|
| 61 |
+ flMtu = flag.Int([]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")
|
|
| 62 | 62 |
flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by tls-verify flags")
|
| 63 | 63 |
flTlsVerify = flag.Bool([]string{"-tlsverify"}, false, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)")
|
| 64 | 64 |
flCa = flag.String([]string{"-tlscacert"}, dockerConfDir+defaultCaFile, "Trust only remotes providing a certificate signed by the CA given here")
|
| ... | ... |
@@ -68,7 +68,7 @@ func main() {
|
| 68 | 68 |
) |
| 69 | 69 |
flag.Var(&flDns, []string{"#dns", "-dns"}, "Force docker to use specific DNS servers")
|
| 70 | 70 |
flag.Var(&flDnsSearch, []string{"-dns-search"}, "Force Docker to use specific DNS search domains")
|
| 71 |
- flag.Var(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.")
|
|
| 71 |
+ flag.Var(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode\nspecified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.")
|
|
| 72 | 72 |
|
| 73 | 73 |
flag.Parse() |
| 74 | 74 |
|
| ... | ... |
@@ -809,33 +809,39 @@ Run a command in a new container |
| 809 | 809 |
|
| 810 | 810 |
Usage: docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
| 811 | 811 |
|
| 812 |
- -a, --attach=[]: Attach to stdin, stdout or stderr. |
|
| 813 |
- -c, --cpu-shares=0: CPU shares (relative weight) |
|
| 814 |
- --cidfile="": Write the container ID to the file |
|
| 815 |
- -d, --detach=false: Detached mode: Run container in the background, print new container id |
|
| 816 |
- --dns=[]: Set custom dns servers |
|
| 817 |
- --dns-search=[]: Set custom dns search domains |
|
| 818 |
- -e, --env=[]: Set environment variables |
|
| 819 |
- --entrypoint="": Overwrite the default entrypoint of the image |
|
| 820 |
- --env-file=[]: Read in a line delimited file of ENV variables |
|
| 821 |
- --expose=[]: Expose a port from the container without publishing it to your host |
|
| 822 |
- -h, --hostname="": Container host name |
|
| 823 |
- -i, --interactive=false: Keep stdin open even if not attached |
|
| 824 |
- --link=[]: Add link to another container (name:alias) |
|
| 825 |
- --lxc-conf=[]: (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1" |
|
| 826 |
- -m, --memory="": Memory limit (format: <number><optional unit>, where unit = b, k, m or g) |
|
| 827 |
- --name="": Assign a name to the container |
|
| 828 |
- --net="bridge": Set the Network mode for the container ('bridge': creates a new network stack for the container on the docker bridge, 'none': no networking for this container, 'container:<name|id>': reuses another container network stack), 'host': use the host network stack inside the container
|
|
| 829 |
- -P, --publish-all=false: Publish all exposed ports to the host interfaces |
|
| 830 |
- -p, --publish=[]: Publish a container's port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) (use 'docker port' to see the actual mapping) |
|
| 831 |
- --privileged=false: Give extended privileges to this container |
|
| 832 |
- --rm=false: Automatically remove the container when it exits (incompatible with -d) |
|
| 833 |
- --sig-proxy=true: Proxify all received signal to the process (even in non-tty mode) |
|
| 834 |
- -t, --tty=false: Allocate a pseudo-tty |
|
| 835 |
- -u, --user="": Username or UID |
|
| 836 |
- -v, --volume=[]: Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container) |
|
| 837 |
- --volumes-from=[]: Mount volumes from the specified container(s) |
|
| 838 |
- -w, --workdir="": Working directory inside the container |
|
| 812 |
+ -a, --attach=[] Attach to stdin, stdout or stderr. |
|
| 813 |
+ -c, --cpu-shares=0 CPU shares (relative weight) |
|
| 814 |
+ --cidfile="" Write the container ID to the file |
|
| 815 |
+ -d, --detach=false Detached mode: Run container in the background, print new container id |
|
| 816 |
+ --dns=[] Set custom dns servers |
|
| 817 |
+ --dns-search=[] Set custom dns search domains |
|
| 818 |
+ -e, --env=[] Set environment variables |
|
| 819 |
+ --entrypoint="" Overwrite the default entrypoint of the image |
|
| 820 |
+ --env-file=[] Read in a line delimited file of ENV variables |
|
| 821 |
+ --expose=[] Expose a port from the container without publishing it to your host |
|
| 822 |
+ -h, --hostname="" Container host name |
|
| 823 |
+ -i, --interactive=false Keep stdin open even if not attached |
|
| 824 |
+ --link=[] Add link to another container (name:alias) |
|
| 825 |
+ --lxc-conf=[] (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1" |
|
| 826 |
+ -m, --memory="" Memory limit (format: <number><optional unit>, where unit = b, k, m or g) |
|
| 827 |
+ --name="" Assign a name to the container |
|
| 828 |
+ --net="bridge" Set the Network mode for the container |
|
| 829 |
+ 'bridge': creates a new network stack for the container on the docker bridge |
|
| 830 |
+ 'none': no networking for this container |
|
| 831 |
+ 'container:<name|id>': reuses another container network stack |
|
| 832 |
+ 'host': use the host network stack inside the contaner |
|
| 833 |
+ -p, --publish=[] Publish a container's port to the host |
|
| 834 |
+ format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort |
|
| 835 |
+ (use 'docker port' to see the actual mapping) |
|
| 836 |
+ -P, --publish-all=false Publish all exposed ports to the host interfaces |
|
| 837 |
+ --privileged=false Give extended privileges to this container |
|
| 838 |
+ --rm=false Automatically remove the container when it exits (incompatible with -d) |
|
| 839 |
+ --sig-proxy=true Proxify all received signal to the process (even in non-tty mode) |
|
| 840 |
+ -t, --tty=false Allocate a pseudo-tty |
|
| 841 |
+ -u, --user="" Username or UID |
|
| 842 |
+ -v, --volume=[] Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container) |
|
| 843 |
+ --volumes-from=[] Mount volumes from the specified container(s) |
|
| 844 |
+ -w, --workdir="" Working directory inside the container |
|
| 839 | 845 |
|
| 840 | 846 |
The `docker run` command first `creates` a writeable container layer over the |
| 841 | 847 |
specified image, and then `starts` it using the specified command. That is, |
| ... | ... |
@@ -138,6 +138,11 @@ PID files): |
| 138 | 138 |
|
| 139 | 139 |
--dns=[] : Set custom dns servers for the container |
| 140 | 140 |
--net="bridge": Set the Network mode for the container ('bridge': creates a new network stack for the container on the docker bridge, 'none': no networking for this container, 'container:<name|id>': reuses another container network stack), 'host': use the host network stack inside the container
|
| 141 |
+ --net="bridge" Set the Network mode for the container |
|
| 142 |
+ 'bridge': creates a new network stack for the container on the docker bridge |
|
| 143 |
+ 'none': no networking for this container |
|
| 144 |
+ 'container:<name|id>': reuses another container network stack |
|
| 145 |
+ 'host': use the host network stack inside the contaner |
|
| 141 | 146 |
|
| 142 | 147 |
By default, all containers have networking enabled and they can make any |
| 143 | 148 |
outgoing connections. The operator can completely disable networking |
| ... | ... |
@@ -2,6 +2,7 @@ package main |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
+ |
|
| 5 | 6 |
flag "github.com/dotcloud/docker/pkg/mflag" |
| 6 | 7 |
) |
| 7 | 8 |
|
| ... | ... |
@@ -19,15 +20,17 @@ func init() {
|
| 19 | 19 |
flag.IntVar(&i, []string{"-integer", "-number"}, -1, "a simple integer")
|
| 20 | 20 |
flag.StringVar(&str, []string{"s", "#hidden", "-string"}, "", "a simple string") //-s -hidden and --string will work, but -hidden won't be in the usage
|
| 21 | 21 |
flag.BoolVar(&h, []string{"h", "#help", "-help"}, false, "display the help")
|
| 22 |
+ flag.StringVar(&str, []string{"mode"}, "mode1", "set the mode\nmode1: use the mode1\nmode2: use the mode2\nmode3: use the mode3")
|
|
| 22 | 23 |
flag.Parse() |
| 23 | 24 |
} |
| 24 | 25 |
func main() {
|
| 25 | 26 |
if h {
|
| 26 | 27 |
flag.PrintDefaults() |
| 28 |
+ } else {
|
|
| 29 |
+ fmt.Printf("s/#hidden/-string: %s\n", str)
|
|
| 30 |
+ fmt.Printf("b: %b\n", b)
|
|
| 31 |
+ fmt.Printf("-bool: %b\n", b2)
|
|
| 32 |
+ fmt.Printf("s/#hidden/-string(via lookup): %s\n", flag.Lookup("s").Value.String())
|
|
| 33 |
+ fmt.Printf("ARGS: %v\n", flag.Args())
|
|
| 27 | 34 |
} |
| 28 |
- fmt.Printf("s/#hidden/-string: %s\n", str)
|
|
| 29 |
- fmt.Printf("b: %b\n", b)
|
|
| 30 |
- fmt.Printf("-bool: %b\n", b2)
|
|
| 31 |
- fmt.Printf("s/#hidden/-string(via lookup): %s\n", flag.Lookup("s").Value.String())
|
|
| 32 |
- fmt.Printf("ARGS: %v\n", flag.Args())
|
|
| 33 | 35 |
} |
| ... | ... |
@@ -83,6 +83,7 @@ import ( |
| 83 | 83 |
"sort" |
| 84 | 84 |
"strconv" |
| 85 | 85 |
"strings" |
| 86 |
+ "text/tabwriter" |
|
| 86 | 87 |
"time" |
| 87 | 88 |
) |
| 88 | 89 |
|
| ... | ... |
@@ -419,11 +420,12 @@ func Set(name, value string) error {
|
| 419 | 419 |
// PrintDefaults prints, to standard error unless configured |
| 420 | 420 |
// otherwise, the default values of all defined flags in the set. |
| 421 | 421 |
func (f *FlagSet) PrintDefaults() {
|
| 422 |
+ writer := tabwriter.NewWriter(f.out(), 20, 1, 3, ' ', 0) |
|
| 422 | 423 |
f.VisitAll(func(flag *Flag) {
|
| 423 |
- format := " -%s=%s: %s\n" |
|
| 424 |
+ format := " -%s=%s" |
|
| 424 | 425 |
if _, ok := flag.Value.(*stringValue); ok {
|
| 425 | 426 |
// put quotes on the value |
| 426 |
- format = " -%s=%q: %s\n" |
|
| 427 |
+ format = " -%s=%q" |
|
| 427 | 428 |
} |
| 428 | 429 |
names := []string{}
|
| 429 | 430 |
for _, name := range flag.Names {
|
| ... | ... |
@@ -432,9 +434,18 @@ func (f *FlagSet) PrintDefaults() {
|
| 432 | 432 |
} |
| 433 | 433 |
} |
| 434 | 434 |
if len(names) > 0 {
|
| 435 |
- fmt.Fprintf(f.out(), format, strings.Join(names, ", -"), flag.DefValue, flag.Usage) |
|
| 435 |
+ fmt.Fprintf(writer, format, strings.Join(names, ", -"), flag.DefValue) |
|
| 436 |
+ for i, line := range strings.Split(flag.Usage, "\n") {
|
|
| 437 |
+ if i != 0 {
|
|
| 438 |
+ line = " " + line |
|
| 439 |
+ } |
|
| 440 |
+ fmt.Fprintln(writer, "\t", line) |
|
| 441 |
+ } |
|
| 442 |
+ // start := fmt.Sprintf(format, strings.Join(names, ", -"), flag.DefValue) |
|
| 443 |
+ // fmt.Fprintln(f.out(), start, strings.Replace(flag.Usage, "\n", "\n"+strings.Repeat(" ", len(start)+1), -1))
|
|
| 436 | 444 |
} |
| 437 | 445 |
}) |
| 446 |
+ writer.Flush() |
|
| 438 | 447 |
} |
| 439 | 448 |
|
| 440 | 449 |
// PrintDefaults prints to standard error the default values of all defined command-line flags. |
| ... | ... |
@@ -62,7 +62,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf |
| 62 | 62 |
flUser = cmd.String([]string{"u", "-user"}, "", "Username or UID")
|
| 63 | 63 |
flWorkingDir = cmd.String([]string{"w", "-workdir"}, "", "Working directory inside the container")
|
| 64 | 64 |
flCpuShares = cmd.Int64([]string{"c", "-cpu-shares"}, 0, "CPU shares (relative weight)")
|
| 65 |
- flNetMode = cmd.String([]string{"-net"}, "bridge", "Set the Network mode for the container ('bridge': creates a new network stack for the container on the docker bridge, 'none': no networking for this container, 'container:<name|id>': reuses another container network stack), 'host': use the host network stack inside the container")
|
|
| 65 |
+ 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 contaner")
|
|
| 66 | 66 |
// For documentation purpose |
| 67 | 67 |
_ = cmd.Bool([]string{"#sig-proxy", "-sig-proxy"}, true, "Proxify all received signal to the process (even in non-tty mode)")
|
| 68 | 68 |
_ = cmd.String([]string{"#name", "-name"}, "", "Assign a name to the container")
|
| ... | ... |
@@ -74,7 +74,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf |
| 74 | 74 |
cmd.Var(&flEnv, []string{"e", "-env"}, "Set environment variables")
|
| 75 | 75 |
cmd.Var(&flEnvFile, []string{"-env-file"}, "Read in a line delimited file of ENV variables")
|
| 76 | 76 |
|
| 77 |
- cmd.Var(&flPublish, []string{"p", "-publish"}, fmt.Sprintf("Publish a container's port to the host (format: %s) (use 'docker port' to see the actual mapping)", nat.PortSpecTemplateFormat))
|
|
| 77 |
+ 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))
|
|
| 78 | 78 |
cmd.Var(&flExpose, []string{"#expose", "-expose"}, "Expose a port from the container without publishing it to your host")
|
| 79 | 79 |
cmd.Var(&flDns, []string{"#dns", "-dns"}, "Set custom dns servers")
|
| 80 | 80 |
cmd.Var(&flDnsSearch, []string{"-dns-search"}, "Set custom dns search domains")
|