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

Function inspectContainerAndCheckState

cli/command/container/attach.go:25–41  ·  view source on GitHub ↗
(ctx context.Context, apiClient client.APIClient, args string)

Source from the content-addressed store, hash-verified

23}
24
25func inspectContainerAndCheckState(ctx context.Context, apiClient client.APIClient, args string) (*container.InspectResponse, error) {
26 c, err := apiClient.ContainerInspect(ctx, args, client.ContainerInspectOptions{})
27 if err != nil {
28 return nil, err
29 }
30 if !c.Container.State.Running {
31 return nil, errors.New("cannot attach to a stopped container, start it first")
32 }
33 if c.Container.State.Paused {
34 return nil, errors.New("cannot attach to a paused container, unpause it first")
35 }
36 if c.Container.State.Restarting {
37 return nil, errors.New("cannot attach to a restarting container, wait until it is running")
38 }
39
40 return &c.Container, nil
41}
42
43// newAttachCommand creates a new cobra.Command for `docker attach`
44func newAttachCommand(dockerCLI command.Cli) *cobra.Command {

Callers 1

RunAttachFunction · 0.85

Calls 1

ContainerInspectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…