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

Method RuntimeAPIVersion

pkg/compose/compose.go:511–531  ·  pkg/compose/compose.go::composeService.RuntimeAPIVersion

RuntimeAPIVersion returns the negotiated API version that will be used for requests to the Docker daemon. It triggers version negotiation via Ping so that version-gated request shaping matches the version subsequent API calls will actually use. After negotiation, Compose should never rely on featur

(ctx context.Context)

Source from the content-addressed store, hash-verified

509// After negotiation, Compose should never rely on features or request attributes
510// not defined by this API version, even if the daemon's raw version is higher.
511func (s *composeService) RuntimeAPIVersion(ctx context.Context) (string, error) {
512 s.runtimeAPIVersion.mu.Lock()
513 defer s.runtimeAPIVersion.mu.Unlock()
514 if s.runtimeAPIVersion.val != "" {
515 return s.runtimeAPIVersion.val, nil
516 }
517
518 cli := s.apiClient()
519 _, err := cli.Ping(ctx, client.PingOptions{NegotiateAPIVersion: true})
520 if err != nil {
521 return "", err
522 }
523
524 version := cli.ClientVersion()
525 if version == "" {
526 return "", fmt.Errorf("docker client returned empty version after successful API negotiation")
527 }
528
529 s.runtimeAPIVersion.val = version
530 return s.runtimeAPIVersion.val, nil
531}

Calls 4

apiClientMethod · 0.95
LockMethod · 0.45
PingMethod · 0.45
ClientVersionMethod · 0.45