--group-add was used for specifying groups for both service create
and service update. For create it was confusing since we don't have
an existing set of groups. Instead I added --group to create, and
moved --group-add to service update only, like --group-rm
This deals with issue 27646
Signed-off-by: Lily Guo <lily.guo@docker.com>
Update flag documentation
Specify that --group, --group-add and --groupd-rm refers to
supplementary user groups
Signed-off-by: Lily Guo <lily.guo@docker.com>
Fix docs for groups and update completion scripts
Signed-off-by: Lily Guo <lily.guo@docker.com>
| ... | ... |
@@ -39,6 +39,7 @@ func newCreateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 39 | 39 |
flags.StringSliceVar(&opts.constraints, flagConstraint, []string{}, "Placement constraints")
|
| 40 | 40 |
flags.StringSliceVar(&opts.networks, flagNetwork, []string{}, "Network attachments")
|
| 41 | 41 |
flags.VarP(&opts.endpoint.ports, flagPublish, "p", "Publish a port as a node port") |
| 42 |
+ flags.StringSliceVar(&opts.groups, flagGroup, []string{}, "Set one or more supplementary user groups for the container")
|
|
| 42 | 43 |
|
| 43 | 44 |
flags.SetInterspersed(false) |
| 44 | 45 |
return cmd |
| ... | ... |
@@ -583,7 +583,6 @@ func addServiceFlags(cmd *cobra.Command, opts *serviceOptions) {
|
| 583 | 583 |
|
| 584 | 584 |
flags.StringVarP(&opts.workdir, flagWorkdir, "w", "", "Working directory inside the container") |
| 585 | 585 |
flags.StringVarP(&opts.user, flagUser, "u", "", "Username or UID (format: <name|uid>[:<group|gid>])") |
| 586 |
- flags.StringSliceVar(&opts.groups, flagGroupAdd, []string{}, "Add additional user groups to the container")
|
|
| 587 | 586 |
|
| 588 | 587 |
flags.Var(&opts.resources.limitCPU, flagLimitCPU, "Limit CPUs") |
| 589 | 588 |
flags.Var(&opts.resources.limitMemBytes, flagLimitMemory, "Limit Memory") |
| ... | ... |
@@ -630,6 +629,7 @@ const ( |
| 630 | 630 |
flagEnvFile = "env-file" |
| 631 | 631 |
flagEnvRemove = "env-rm" |
| 632 | 632 |
flagEnvAdd = "env-add" |
| 633 |
+ flagGroup = "group" |
|
| 633 | 634 |
flagGroupAdd = "group-add" |
| 634 | 635 |
flagGroupRemove = "group-rm" |
| 635 | 636 |
flagLabel = "label" |
| ... | ... |
@@ -42,7 +42,7 @@ func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 42 | 42 |
addServiceFlags(cmd, opts) |
| 43 | 43 |
|
| 44 | 44 |
flags.Var(newListOptsVar(), flagEnvRemove, "Remove an environment variable") |
| 45 |
- flags.Var(newListOptsVar(), flagGroupRemove, "Remove previously added user groups from the container") |
|
| 45 |
+ flags.Var(newListOptsVar(), flagGroupRemove, "Remove previously added supplementary user groups from the container") |
|
| 46 | 46 |
flags.Var(newListOptsVar(), flagLabelRemove, "Remove a label by its key") |
| 47 | 47 |
flags.Var(newListOptsVar(), flagContainerLabelRemove, "Remove a container label by its key") |
| 48 | 48 |
flags.Var(newListOptsVar(), flagMountRemove, "Remove a mount by its target path") |
| ... | ... |
@@ -54,6 +54,7 @@ func newUpdateCommand(dockerCli *command.DockerCli) *cobra.Command {
|
| 54 | 54 |
flags.Var(&opts.mounts, flagMountAdd, "Add or update a mount on a service") |
| 55 | 55 |
flags.StringSliceVar(&opts.constraints, flagConstraintAdd, []string{}, "Add or update placement constraints")
|
| 56 | 56 |
flags.Var(&opts.endpoint.ports, flagPublishAdd, "Add or update a published port") |
| 57 |
+ flags.StringSliceVar(&opts.groups, flagGroupAdd, []string{}, "Add additional supplementary user groups to the container")
|
|
| 57 | 58 |
return cmd |
| 58 | 59 |
} |
| 59 | 60 |
|
| ... | ... |
@@ -2573,7 +2573,6 @@ _docker_service_update() {
|
| 2573 | 2573 |
--endpoint-mode |
| 2574 | 2574 |
--env -e |
| 2575 | 2575 |
--force |
| 2576 |
- --group-add |
|
| 2577 | 2576 |
--health-cmd |
| 2578 | 2577 |
--health-interval |
| 2579 | 2578 |
--health-retries |
| ... | ... |
@@ -2616,6 +2615,7 @@ _docker_service_update() {
|
| 2616 | 2616 |
options_with_args="$options_with_args |
| 2617 | 2617 |
--container-label |
| 2618 | 2618 |
--env-file |
| 2619 |
+ --group |
|
| 2619 | 2620 |
--mode |
| 2620 | 2621 |
--name |
| 2621 | 2622 |
" |
| ... | ... |
@@ -2629,6 +2629,10 @@ _docker_service_update() {
|
| 2629 | 2629 |
COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) ) |
| 2630 | 2630 |
return |
| 2631 | 2631 |
;; |
| 2632 |
+ --group) |
|
| 2633 |
+ COMPREPLY=( $(compgen -g -- "$cur") ) |
|
| 2634 |
+ return |
|
| 2635 |
+ ;; |
|
| 2632 | 2636 |
esac |
| 2633 | 2637 |
fi |
| 2634 | 2638 |
if [ "$subcommand" = "update" ] ; then |
| ... | ... |
@@ -2636,11 +2640,16 @@ _docker_service_update() {
|
| 2636 | 2636 |
--arg |
| 2637 | 2637 |
--container-label-add |
| 2638 | 2638 |
--container-label-rm |
| 2639 |
+ --group-add |
|
| 2639 | 2640 |
--group-rm |
| 2640 | 2641 |
--image |
| 2641 | 2642 |
" |
| 2642 | 2643 |
|
| 2643 | 2644 |
case "$prev" in |
| 2645 |
+ --group-add) |
|
| 2646 |
+ COMPREPLY=( $(compgen -g -- "$cur") ) |
|
| 2647 |
+ return |
|
| 2648 |
+ ;; |
|
| 2644 | 2649 |
--group-rm) |
| 2645 | 2650 |
COMPREPLY=( $(compgen -g -- "$cur") ) |
| 2646 | 2651 |
return |
| ... | ... |
@@ -2663,10 +2672,6 @@ _docker_service_update() {
|
| 2663 | 2663 |
__docker_nospace |
| 2664 | 2664 |
return |
| 2665 | 2665 |
;; |
| 2666 |
- --group-add) |
|
| 2667 |
- COMPREPLY=( $(compgen -g -- "$cur") ) |
|
| 2668 |
- return |
|
| 2669 |
- ;; |
|
| 2670 | 2666 |
--log-driver) |
| 2671 | 2667 |
__docker_complete_log_drivers |
| 2672 | 2668 |
return |
| ... | ... |
@@ -1088,7 +1088,6 @@ __docker_service_subcommand() {
|
| 1088 | 1088 |
"($help)*--constraint=[Placement constraints]:constraint: " |
| 1089 | 1089 |
"($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" |
| 1090 | 1090 |
"($help)*"{-e=,--env=}"[Set environment variables]:env: "
|
| 1091 |
- "($help)*--group-add=[Add additional user groups to the container]:group:_groups" |
|
| 1092 | 1091 |
"($help)--health-cmd=[Command to run to check health]:command: " |
| 1093 | 1092 |
"($help)--health-interval=[Time between running the check]:time: " |
| 1094 | 1093 |
"($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" |
| ... | ... |
@@ -1192,7 +1191,8 @@ __docker_service_subcommand() {
|
| 1192 | 1192 |
"($help)*--container-label-add=[Add or update container labels]:label: " \ |
| 1193 | 1193 |
"($help)*--container-label-rm=[Remove a container label by its key]:label: " \ |
| 1194 | 1194 |
"($help)--force[Force update]" \ |
| 1195 |
- "($help)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \ |
|
| 1195 |
+ "($help)*--group-add=[Add additional supplementary user groups to the container]:group:_groups" \ |
|
| 1196 |
+ "($help)*--group-rm=[Remove previously added supplementary user groups from the container]:group:_groups" \ |
|
| 1196 | 1197 |
"($help)--image=[Service image tag]:image:__docker_repositories" \ |
| 1197 | 1198 |
"($help)--rollback[Rollback to previous specification]" \ |
| 1198 | 1199 |
"($help -)1:service:__docker_complete_services" && ret=0 |
| ... | ... |
@@ -1465,7 +1465,7 @@ __docker_subcommand() {
|
| 1465 | 1465 |
"($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: " |
| 1466 | 1466 |
"($help)*--env-file=[Read environment variables from a file]:environment file:_files" |
| 1467 | 1467 |
"($help)*--expose=[Expose a port from the container without publishing it]: " |
| 1468 |
- "($help)*--group-add=[Add additional groups to run as]:group:_groups" |
|
| 1468 |
+ "($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups" |
|
| 1469 | 1469 |
"($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
|
| 1470 | 1470 |
"($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
|
| 1471 | 1471 |
"($help)--ip=[Container IPv4 address]:IPv4: " |
| ... | ... |
@@ -26,7 +26,7 @@ Options: |
| 26 | 26 |
--endpoint-mode string Endpoint mode (vip or dnsrr) |
| 27 | 27 |
-e, --env value Set environment variables (default []) |
| 28 | 28 |
--env-file value Read in a file of environment variables (default []) |
| 29 |
- --group-add value Add additional user groups to the container (default []) |
|
| 29 |
+ --group value Set one or more supplementary user groups for the container (default []) |
|
| 30 | 30 |
--health-cmd string Command to run to check health |
| 31 | 31 |
--health-interval duration Time between running the check |
| 32 | 32 |
--health-retries int Consecutive failures needed to report unhealthy |
| ... | ... |
@@ -30,8 +30,8 @@ Options: |
| 30 | 30 |
--env-add value Add or update environment variables (default []) |
| 31 | 31 |
--env-rm value Remove an environment variable (default []) |
| 32 | 32 |
--force Force update even if no changes require it |
| 33 |
- --group-add value Add additional user groups to the container (default []) |
|
| 34 |
- --group-rm value Remove previously added user groups from the container (default []) |
|
| 33 |
+ --group-add value Add additional supplementary user groups to the container (default []) |
|
| 34 |
+ --group-rm value Remove previously added supplementary user groups from the container (default []) |
|
| 35 | 35 |
--health-cmd string Command to run to check health |
| 36 | 36 |
--health-interval duration Time between running the check |
| 37 | 37 |
--health-retries int Consecutive failures needed to report unhealthy |
| ... | ... |
@@ -235,7 +235,7 @@ func (s *DockerSwarmSuite) TestSwarmServiceWithGroup(c *check.C) {
|
| 235 | 235 |
d := s.AddDaemon(c, true, true) |
| 236 | 236 |
|
| 237 | 237 |
name := "top" |
| 238 |
- out, err := d.Cmd("service", "create", "--name", name, "--user", "root:root", "--group-add", "wheel", "--group-add", "audio", "--group-add", "staff", "--group-add", "777", "busybox", "top")
|
|
| 238 |
+ out, err := d.Cmd("service", "create", "--name", name, "--user", "root:root", "--group", "wheel", "--group", "audio", "--group", "staff", "--group", "777", "busybox", "top")
|
|
| 239 | 239 |
c.Assert(err, checker.IsNil) |
| 240 | 240 |
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "") |
| 241 | 241 |
|