newPauseCommand creates a new cobra.Command for "docker container pause"
(dockerCLI command.Cli)
| 19 | |
| 20 | // newPauseCommand creates a new cobra.Command for "docker container pause" |
| 21 | func newPauseCommand(dockerCLI command.Cli) *cobra.Command { |
| 22 | var opts pauseOptions |
| 23 | |
| 24 | return &cobra.Command{ |
| 25 | Use: "pause CONTAINER [CONTAINER...]", |
| 26 | Short: "Pause all processes within one or more containers", |
| 27 | Args: cli.RequiresMinArgs(1), |
| 28 | RunE: func(cmd *cobra.Command, args []string) error { |
| 29 | opts.containers = args |
| 30 | return runPause(cmd.Context(), dockerCLI, &opts) |
| 31 | }, |
| 32 | Annotations: map[string]string{ |
| 33 | "aliases": "docker container pause, docker pause", |
| 34 | }, |
| 35 | ValidArgsFunction: completion.ContainerNames(dockerCLI, false, func(ctr container.Summary) bool { |
| 36 | return ctr.State != container.StatePaused |
| 37 | }), |
| 38 | DisableFlagsInUseLine: true, |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func runPause(ctx context.Context, dockerCLI command.Cli, opts *pauseOptions) error { |
| 43 | apiClient := dockerCLI.Client() |
searching dependent graphs…