moby / moby

The Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
https://mobyproject.org/
Apache License 2.0
68.58k stars 18.64k forks source link

`dockerd -h` does not display some default value for options #27663

Open allencloud opened 7 years ago

allencloud commented 7 years ago

Description I execute dockerd -h in docker 1.12.2. And I found some options has no default value while some has. I think some options has a default value and it is just no showing in the output.

command dockerd -d:

root@ubuntu:~# dockerd -h
Usage: dockerd [OPTIONS]

A self-sufficient runtime for containers.

Options:

  --add-runtime=[]                         Register an additional OCI compatible runtime
  --api-cors-header                        Set CORS headers in the remote API
  --authorization-plugin=[]                Authorization plugins to load
  -b, --bridge                             Attach containers to a network bridge
  --bip                                    Specify network bridge IP
  --cgroup-parent                          Set parent cgroup for all containers
  --cluster-advertise                      Address or interface name to advertise
  --cluster-store                          URL of the distributed storage backend
  --cluster-store-opt=map[]                Set cluster store options
  --config-file=/etc/docker/daemon.json    Daemon configuration file
  --containerd                             Path to containerd socket
  -D, --debug                              Enable debug mode
  --default-gateway                        Container default gateway IPv4 address
  --default-gateway-v6                     Container default gateway IPv6 address
  --default-runtime=runc                   Default OCI runtime for containers
  --default-ulimit=[]                      Default ulimits for containers
  --disable-legacy-registry                Disable contacting legacy registries
  --dns=[]                                 DNS server to use
  --dns-opt=[]                             DNS options to use
  --dns-search=[]                          DNS search domains to use
  --exec-opt=[]                            Runtime execution options
  --exec-root=/var/run/docker              Root directory for execution state files
  --fixed-cidr                             IPv4 subnet for fixed IPs
  --fixed-cidr-v6                          IPv6 subnet for fixed IPs
  -G, --group=docker                       Group for the unix socket
  -g, --graph=/var/lib/docker              Root of the Docker runtime
  -H, --host=[]                            Daemon socket(s) to connect to
  -h, --help                               Print usage
  --icc=true                               Enable inter-container communication
  --insecure-registry=[]                   Enable insecure registry communication
  --ip=0.0.0.0                             Default IP when binding container ports
  --ip-forward=true                        Enable net.ipv4.ip_forward
  --ip-masq=true                           Enable IP masquerading
  --iptables=true                          Enable addition of iptables rules
  --ipv6                                   Enable IPv6 networking
  -l, --log-level=info                     Set the logging level
  --label=[]                               Set key=value labels to the daemon
  --live-restore                           Enable live restore of docker when containers are still running
  --log-driver=json-file                   Default driver for container logs
  --log-opt=map[]                          Default log driver options for containers
  --max-concurrent-downloads=3             Set the max concurrent downloads for each pull
  --max-concurrent-uploads=5               Set the max concurrent uploads for each push
  --mtu                                    Set the containers network MTU
  --oom-score-adjust=-500                  Set the oom_score_adj for the daemon
  -p, --pidfile=/var/run/docker.pid        Path to use for daemon PID file
  --raw-logs                               Full timestamps without ANSI coloring
  --registry-mirror=[]                     Preferred Docker registry mirror
  -s, --storage-driver                     Storage driver to use
  --selinux-enabled                        Enable selinux support
  --storage-opt=[]                         Storage driver options
  --swarm-default-advertise-addr           Set default address or interface for swarm advertised address
  --tls                                    Use TLS; implied by --tlsverify
  --tlscacert=~/.docker/ca.pem             Trust certs signed only by this CA
  --tlscert=~/.docker/cert.pem             Path to TLS certificate file
  --tlskey=~/.docker/key.pem               Path to TLS key file
  --tlsverify                              Use TLS and verify the remote
  --userland-proxy=true                    Use userland proxy for loopback traffic
  --userns-remap                           User/Group setting for user namespaces
  -v, --version                            Print version information and quit

We will see that like --icc=true Enable inter-container communication it has a default value of true.

While I think the default value of --live-restore Enable live restore of docker when containers are still running is false. But it did not show this default value.

Maybe it is command displaying issue.

Steps to reproduce the issue: 1. 2. 3.

Describe the results you received:

Describe the results you expected:

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

root@ubuntu:~# docker version
Client:
 Version:      1.12.2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   bb80604
 Built:        Tue Oct 11 18:19:35 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.2
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   bb80604
 Built:        Tue Oct 11 18:19:35 2016
 OS/Arch:      linux/amd64

Output of docker info:

root@ubuntu:~# docker info
Containers: 29
 Running: 5
 Paused: 0
 Stopped: 24
Images: 64
Server Version: 1.12.2
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 514
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: overlay bridge null host
Swarm: active
 NodeID: 2iu5iv9fk2sdxppoqnttfaaa8
 Is Manager: true
 ClusterID: 0c0xhuqs7vvw0t8azx2b5zth9
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 5 weeks
 Node Address: 192.168.59.103
Runtimes: runc
Default Runtime: runc
Security Options: apparmor
Kernel Version: 3.19.0-25-generic
Operating System: Ubuntu 14.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 1.954 GiB
Name: ubuntu
ID: HRBI:EV6M:3NAC:CXZ3:BDS7:UOKL:PD6Y:ZCK4:V3PF:V7MR:CU2Y:3LGG
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 57
 Goroutines: 193
 System Time: 2016-10-22T23:52:43.511871935+08:00
 EventsListeners: 5
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Labels:
 a=b
Insecure Registries:
 192.168.1.22:5500
 127.0.0.0/8

Additional environment details (AWS, VirtualBox, physical, etc.):

thaJeztah commented 7 years ago

Live restore is actually disable by default, and flags show the default value that's set, so not sure there's anything to do here?

https://github.com/docker/docker/blob/91312f71aabe4f0840060049259fc6dbfcc62cd2/daemon/config_unix.go#L94

allencloud commented 7 years ago

@thaJeztah
Yeah, it is disabled by default. I mean maybe it shows --live-restore=false Enable live restore of docker when containers are still running.

Sorry for my typo in the issue description. Now Updated.

thaJeztah commented 7 years ago

We actually had that in old versions of docker, e,g, --help=false, but this turned out to be very confusing, because people tried --help=false to show help, but that did the exact opposite

allencloud commented 7 years ago

Oh, I got it. Confusion will come. How about in this kind of default format?

root@ubuntu:~# docker service create --help

Usage:  docker service create [OPTIONS] IMAGE [COMMAND] [ARG...]

Create a new service

Options:
      --constraint value               Placement constraints (default [])
      --container-label value          Container labels (default [])
      --endpoint-mode string           Endpoint mode (vip or dnsrr)
  -e, --env value                      Set environment variables (default [])
      --help                           Print usage
  -l, --label value                    Service labels (default [])
      --limit-cpu value                Limit CPUs (default 0.000)
      --limit-memory value             Limit Memory (default 0 B)
      --log-driver string              Logging driver for service
      --log-opt value                  Logging driver options (default [])
      --mode string                    Service mode (replicated or global) (default "replicated")
      --mount value                    Attach a mount to the service
      --name string                    Service name
      --network value                  Network attachments (default [])
  -p, --publish value                  Publish a port as a node port (default [])
      --replicas value                 Number of tasks (default none)
      --reserve-cpu value              Reserve CPUs (default 0.000)
      --reserve-memory value           Reserve Memory (default 0 B)
      --restart-condition string       Restart when condition is met (none, on-failure, or any)
      --restart-delay value            Delay between restart attempts (default none)
      --restart-max-attempts value     Maximum number of restarts before giving up (default none)
      --restart-window value           Window used to evaluate the restart policy (default none)
      --stop-grace-period value        Time to wait before force killing a container (default none)
      --update-delay duration          Delay between updates
      --update-failure-action string   Action on update failure (pause|continue) (default "pause")
      --update-parallelism uint        Maximum number of tasks updated simultaneously (0 to update all at once) (default 1)
  -u, --user string                    Username or UID
      --with-registry-auth             Send registry authentication details to swarm agents
  -w, --workdir string                 Working directory inside the container

There is (default none) in

--restart-max-attempts value     Maximum number of restarts before giving up (default none)
      --restart-window value           Window used to evaluate the restart policy (default none)
thaJeztah commented 7 years ago

Have you tried current master? It should already look like that; 1.12 still uses mflags, master (1.13) switches to Cobra / pflags for he CLI

allencloud commented 7 years ago

I am afraid nothing changed in docker/master. Here is the test.

root@10-11-11-54:~/docker/bundles/1.13.0-dev/binary-daemon# ./dockerd -v
Docker version 1.13.0-dev, build 1f9bece
root@10-11-11-54:~/docker/bundles/1.13.0-dev/binary-daemon# ./dockerd --help

Usage:  dockerd [OPTIONS]

A self-sufficient runtime for containers.

Options:
      --add-runtime runtime                   Register an additional OCI compatible runtime (default [])
      --api-cors-header string                Set CORS headers in the remote API
      --authorization-plugin list             Authorization plugins to load (default [])
      --bip string                            Specify network bridge IP
  -b, --bridge string                         Attach containers to a network bridge
      --cgroup-parent string                  Set parent cgroup for all containers
      --cluster-advertise string              Address or interface name to advertise
      --cluster-store string                  URL of the distributed storage backend
      --cluster-store-opt map                 Set cluster store options (default map[])
      --config-file string                    Daemon configuration file (default "/etc/docker/daemon.json")
      --containerd string                     Path to containerd socket
  -D, --debug                                 Enable debug mode
      --default-gateway ip                    Container default gateway IPv4 address
      --default-gateway-v6 ip                 Container default gateway IPv6 address
      --default-runtime string                Default OCI runtime for containers (default "runc")
      --default-ulimit ulimit                 Default ulimits for containers (default [])
      --disable-legacy-registry               Disable contacting legacy registries
      --dns list                              DNS server to use (default [])
      --dns-opt list                          DNS options to use (default [])
      --dns-search list                       DNS search domains to use (default [])
      --exec-opt list                         Runtime execution options (default [])
      --exec-root string                      Root directory for execution state files (default "/var/run/docker")
      --fixed-cidr string                     IPv4 subnet for fixed IPs
      --fixed-cidr-v6 string                  IPv6 subnet for fixed IPs
  -g, --graph string                          Root of the Docker runtime (default "/var/lib/docker")
  -G, --group string                          Group for the unix socket (default "docker")
      --help                                  Print usage
  -H, --host list                             Daemon socket(s) to connect to (default [])
      --icc                                   Enable inter-container communication (default true)
      --init                                  Run an init in the container to forward signals and reap processes
      --init-path string                      Path to the docker-init binary
      --insecure-registry list                Enable insecure registry communication (default [])
      --ip ip                                 Default IP when binding container ports (default 0.0.0.0)
      --ip-forward                            Enable net.ipv4.ip_forward (default true)
      --ip-masq                               Enable IP masquerading (default true)
      --iptables                              Enable addition of iptables rules (default true)
      --ipv6                                  Enable IPv6 networking
      --label list                            Set key=value labels to the daemon (default [])
      --live-restore                          Enable live restore of docker when containers are still running
      --log-driver string                     Default driver for container logs (default "json-file")
  -l, --log-level string                      Set the logging level (debug, info, warn, error, fatal) (default "info")
      --log-opt map                           Default log driver options for containers (default map[])
      --max-concurrent-downloads int          Set the max concurrent downloads for each pull (default 3)
      --max-concurrent-uploads int            Set the max concurrent uploads for each push (default 5)
      --mtu int                               Set the containers network MTU
      --oom-score-adjust int                  Set the oom_score_adj for the daemon (default -500)
  -p, --pidfile string                        Path to use for daemon PID file (default "/var/run/docker.pid")
      --raw-logs                              Full timestamps without ANSI coloring
      --registry-mirror list                  Preferred Docker registry mirror (default [])
      --selinux-enabled                       Enable selinux support
      --shutdown-timeout int                  Set the default shutdown timeout (default 15)
  -s, --storage-driver string                 Storage driver to use
      --storage-opt list                      Storage driver options (default [])
      --swarm-default-advertise-addr string   Set default address or interface for swarm advertised address
      --tls                                   Use TLS; implied by --tlsverify
      --tlscacert string                      Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string                        Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string                         Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify                             Use TLS and verify the remote
      --userland-proxy                        Use userland proxy for loopback traffic (default true)
      --userland-proxy-path string            Path to the userland proxy binary
      --userns-remap string                   User/Group setting for user namespaces
  -v, --version                               Print version information and quit
thaJeztah commented 7 years ago

Sorry, looks like I misinterpreted what change you wanted, can you point out exactly what you thing should be changed? Defaults are currently based in the actual default as is set on the flag, but perhaps I don't understand

allencloud commented 7 years ago

OK, @thaJeztah maybe my expression is somewhat ambiguous.

What I want is that dockerd -h shows all option default value, no matter it is true or false, or an empty slice...

Since I found that in the command help details, like --userland-proxy Use userland proxy for loopback traffic (default true) show a default value of true. While --selinux-enabled Enable selinux support and --live-restore Enable live restore of docker when containers are still running actually has a default value of false but does not show that.

I am not sure if my expression is clear, free to ping me if need more info.