MCPcopy
hub / github.com/keploy/keploy / SetupDocker

Method SetupDocker

pkg/client/app/app.go:85–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83}
84
85func (a *App) SetupDocker() error {
86
87 if a.kind == utils.DockerStart {
88 running, err := a.docker.IsContainerRunning(a.container)
89 if err != nil {
90 return err
91 }
92 if running {
93 return fmt.Errorf("docker container is already in running state")
94 }
95 }
96
97 a.logger.Debug("inside setup docker", zap.String("cmd", a.cmd))
98
99 if HookImpl != nil {
100 newCmd, err := HookImpl.BeforeDockerSetup(context.Background(), a.cmd)
101 if err != nil {
102 utils.LogError(a.logger, err, "hook failed during docker setup")
103 return err
104 }
105 a.cmd = newCmd
106 }
107
108 a.logger.Debug("after before docker setup hook", zap.String("cmd", a.cmd))
109
110 // attaching the init container's PID namespace to the app container
111 err := a.modifyDockerRun(context.Background())
112 if err != nil {
113 utils.LogError(a.logger, err, "failed to attach init pid")
114 return err
115 }
116 return nil
117}
118
119// ModifyDockerRun modifies the existing Docker command to attach the init container's PID namespace
120func (a *App) modifyDockerRun(_ context.Context) error {

Callers 1

SetupMethod · 0.95

Calls 6

modifyDockerRunMethod · 0.95
LogErrorFunction · 0.92
IsContainerRunningMethod · 0.65
DebugMethod · 0.65
BeforeDockerSetupMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected