newStartCommand creates a new cobra.Command for "docker container start".
(dockerCLI command.Cli)
| 30 | |
| 31 | // newStartCommand creates a new cobra.Command for "docker container start". |
| 32 | func newStartCommand(dockerCLI command.Cli) *cobra.Command { |
| 33 | var opts StartOptions |
| 34 | |
| 35 | cmd := &cobra.Command{ |
| 36 | Use: "start [OPTIONS] CONTAINER [CONTAINER...]", |
| 37 | Short: "Start one or more stopped containers", |
| 38 | Args: cli.RequiresMinArgs(1), |
| 39 | RunE: func(cmd *cobra.Command, args []string) error { |
| 40 | opts.Containers = args |
| 41 | return RunStart(cmd.Context(), dockerCLI, &opts) |
| 42 | }, |
| 43 | Annotations: map[string]string{ |
| 44 | "aliases": "docker container start, docker start", |
| 45 | }, |
| 46 | ValidArgsFunction: completion.ContainerNames(dockerCLI, true, func(ctr container.Summary) bool { |
| 47 | return ctr.State == container.StateExited || ctr.State == container.StateCreated |
| 48 | }), |
| 49 | DisableFlagsInUseLine: true, |
| 50 | } |
| 51 | |
| 52 | flags := cmd.Flags() |
| 53 | flags.BoolVarP(&opts.Attach, "attach", "a", false, "Attach STDOUT/STDERR and forward signals") |
| 54 | flags.BoolVarP(&opts.OpenStdin, "interactive", "i", false, "Attach container's STDIN") |
| 55 | flags.StringVar(&opts.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container") |
| 56 | |
| 57 | flags.StringVar(&opts.Checkpoint, "checkpoint", "", "Restore from this checkpoint") |
| 58 | flags.SetAnnotation("checkpoint", "experimental", nil) |
| 59 | flags.SetAnnotation("checkpoint", "ostype", []string{"linux"}) |
| 60 | flags.StringVar(&opts.CheckpointDir, "checkpoint-dir", "", "Use a custom checkpoint storage directory") |
| 61 | flags.SetAnnotation("checkpoint-dir", "experimental", nil) |
| 62 | flags.SetAnnotation("checkpoint-dir", "ostype", []string{"linux"}) |
| 63 | return cmd |
| 64 | } |
| 65 | |
| 66 | // RunStart executes a `start` command |
| 67 | // |
searching dependent graphs…