MCPcopy Index your code
hub / github.com/docker/cli / newAttachCommand

Function newAttachCommand

cli/command/container/attach.go:44–69  ·  view source on GitHub ↗

newAttachCommand creates a new cobra.Command for `docker attach`

(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

42
43// newAttachCommand creates a new cobra.Command for `docker attach`
44func newAttachCommand(dockerCLI command.Cli) *cobra.Command {
45 var opts AttachOptions
46
47 cmd := &cobra.Command{
48 Use: "attach [OPTIONS] CONTAINER",
49 Short: "Attach local standard input, output, and error streams to a running container",
50 Args: cli.ExactArgs(1),
51 RunE: func(cmd *cobra.Command, args []string) error {
52 containerID := args[0]
53 return RunAttach(cmd.Context(), dockerCLI, containerID, &opts)
54 },
55 Annotations: map[string]string{
56 "aliases": "docker container attach, docker attach",
57 },
58 ValidArgsFunction: completion.ContainerNames(dockerCLI, false, func(ctr container.Summary) bool {
59 return ctr.State != container.StatePaused
60 }),
61 DisableFlagsInUseLine: true,
62 }
63
64 flags := cmd.Flags()
65 flags.BoolVar(&opts.NoStdin, "no-stdin", false, "Do not attach STDIN")
66 flags.BoolVar(&opts.Proxy, "sig-proxy", true, "Proxy all received signals to the process")
67 flags.StringVar(&opts.DetachKeys, "detach-keys", "", "Override the key sequence for detaching a container")
68 return cmd
69}
70
71// RunAttach executes an `attach` command
72func RunAttach(ctx context.Context, dockerCLI command.Cli, containerID string, opts *AttachOptions) error {

Callers 2

newContainerCommandFunction · 0.85

Calls 1

RunAttachFunction · 0.85

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…