MCPcopy
hub / github.com/docker/compose / NewComposeService

Function NewComposeService

pkg/compose/compose.go:66–95  ·  pkg/compose/compose.go::NewComposeService

NewComposeService creates a Compose service using Docker CLI. This is the standard constructor that requires command.Cli for full functionality. Example usage: dockerCli, _ := command.NewDockerCli() service := NewComposeService(dockerCli) For advanced configuration with custom overrides, use Se

(dockerCli command.Cli, options ...Option)

Source from the content-addressed store, hash-verified

64// service := NewComposeService(dockerCli,
65// WithStreams(customOut, customErr, customIn))
66func NewComposeService(dockerCli command.Cli, options ...Option) (api.Compose, error) {
67 s := &composeService{
68 dockerCli: dockerCli,
69 clock: clockwork.NewRealClock(),
70 maxConcurrency: -1,
71 dryRun: false,
72 }
73 for _, option := range options {
74 if err := option(s); err != nil {
75 return nil, err
76 }
77 }
78 if s.prompt == nil {
79 s.prompt = func(message string, defaultValue bool) (bool, error) {
80 fmt.Println(message)
81 logrus.Warning("Compose is running without a 'prompt' component to interact with user")
82 return defaultValue, nil
83 }
84 }
85 if s.events == nil {
86 s.events = &ignore{}
87 }
88
89 // If custom streams were provided, wrap the Docker CLI to use them
90 if s.outStream != nil || s.errStream != nil || s.inStream != nil {
91 s.dockerCli = s.wrapDockerCliWithStreams(dockerCli)
92 }
93
94 return s, nil
95}
96
97// WithStreams sets custom I/O streams for output and interaction
98func WithStreams(out, err io.Writer, in io.Reader) Option {

Callers 15

runLogsFunction · 0.92
runCopyFunction · 0.92
runPushFunction · 0.92
runConvertFunction · 0.92
runExportFunction · 0.92
runTopFunction · 0.92
runAttachFunction · 0.92
runUpFunction · 0.92
runVizFunction · 0.92
runRemoveFunction · 0.92
runPullFunction · 0.92
completeServiceNamesFunction · 0.92

Calls 1

Tested by 15

newTestServiceFunction · 0.68
TestDownFunction · 0.68
TestDownRemoveOrphansFunction · 0.68
TestDownRemoveVolumesFunction · 0.68
TestDownRemoveImagesFunction · 0.68
newPreStartTestServiceFunction · 0.68
TestImagesFunction · 0.68
TestStopTimeoutFunction · 0.68
TestLoadProject_BasicFunction · 0.68