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

Method runPreStart

pkg/compose/pre_start.go:60–73  ·  view source on GitHub ↗

runPreStart executes the service's pre_start hooks sequentially, in declared order. Each hook runs as an ephemeral container that shares the service container's volumes via VolumesFrom and is attached to the same networks. A non-zero exit gates service start. With per_replica: false (the only curre

(ctx context.Context, project *types.Project, service types.ServiceConfig, ctr container.Summary, listener api.ContainerEventListener)

Source from the content-addressed store, hash-verified

58// tmpfs mounts are per-replica and not shared. Use named volumes or bind
59// mounts for data the hook produces.
60func (s *composeService) runPreStart(ctx context.Context, project *types.Project, service types.ServiceConfig, ctr container.Summary, listener api.ContainerEventListener) error {
61 // Validate every hook up front so an unsupported entry never triggers any I/O.
62 for i, hook := range service.PreStart {
63 if hook.PerReplica {
64 return fmt.Errorf("service %q pre_start[%d]: per_replica is not yet supported; remove per_replica or set it to false", service.Name, i)
65 }
66 }
67 for i, hook := range service.PreStart {
68 if err := s.runPreStartHook(ctx, project, service, ctr, i, hook, listener); err != nil {
69 return err
70 }
71 }
72 return nil
73}
74
75func (s *composeService) runPreStartHook(
76 ctx context.Context, project *types.Project, service types.ServiceConfig,

Calls 1

runPreStartHookMethod · 0.95