Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ example-provider: ## build example provider for e2e tests
mocks:
mockgen --version >/dev/null 2>&1 || go install go.uber.org/mock/[email protected]
mockgen -destination pkg/mocks/mock_docker_cli.go -package mocks github.com/docker/cli/cli/command Cli
mockgen -destination pkg/mocks/mock_docker_api.go -package mocks github.com/docker/docker/client APIClient
mockgen -destination pkg/mocks/mock_docker_api.go -package mocks github.com/moby/moby/client APIClient
mockgen -destination pkg/mocks/mock_docker_compose_api.go -package mocks -source=./pkg/api/api.go Service

.PHONY: e2e
Expand Down
4 changes: 2 additions & 2 deletions cmd/compose/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

"github.com/distribution/reference"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/api/types/image"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/client/pkg/stringid"
"github.com/spf13/cobra"

"github.com/docker/compose/v5/cmd/formatter"
Expand Down
11 changes: 0 additions & 11 deletions cmd/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
composepaths "github.com/compose-spec/compose-go/v2/paths"
"github.com/compose-spec/compose-go/v2/types"
composegoutils "github.com/compose-spec/compose-go/v2/utils"
"github.com/docker/buildx/util/logutil"
dockercli "github.com/docker/cli/cli"
"github.com/docker/cli/cli-plugins/metadata"
"github.com/docker/cli/cli/command"
Expand Down Expand Up @@ -423,16 +422,6 @@ func (o *BackendOptions) Add(option compose.Option) {

// RootCommand returns the compose command with its child commands
func RootCommand(dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { //nolint:gocyclo
// filter out useless commandConn.CloseWrite warning message that can occur
// when using a remote context that is unreachable: "commandConn.CloseWrite: commandconn: failed to wait: signal: killed"
// https://github.com/docker/cli/blob/e1f24d3c93df6752d3c27c8d61d18260f141310c/cli/connhelper/commandconn/commandconn.go#L203-L215
logrus.AddHook(logutil.NewFilter([]logrus.Level{
Comment on lines -426 to -429
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were removed in docker/cli#6644

logrus.WarnLevel,
},
"commandConn.CloseWrite:",
"commandConn.CloseRead:",
))

opts := ProjectOptions{}
var (
ansi string
Expand Down
2 changes: 1 addition & 1 deletion cmd/compose/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (

"github.com/containerd/platforms"
"github.com/docker/cli/cli/command"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
"github.com/moby/moby/client/pkg/stringid"
"github.com/spf13/cobra"

"github.com/docker/compose/v5/cmd/formatter"
Expand Down
37 changes: 30 additions & 7 deletions cmd/compose/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ package compose

import (
"context"
"errors"
"fmt"
"io"
"regexp"
"strings"

"github.com/docker/cli/cli/command"
"github.com/docker/cli/opts"
"github.com/moby/moby/client"
"github.com/spf13/cobra"

"github.com/docker/compose/v5/cmd/formatter"
Expand Down Expand Up @@ -61,11 +64,32 @@ var acceptedListFilters = map[string]bool{
"name": true,
}

// match returns true if any of the values at key match the source string
func match(filters client.Filters, field, source string) bool {
if f, ok := filters[field]; ok && f[source] {
return true
}

fieldValues := filters[field]
for name2match := range fieldValues {
isMatch, err := regexp.MatchString(name2match, source)
if err != nil {
continue
}
if isMatch {
return true
}
}
return false
}

func runList(ctx context.Context, dockerCli command.Cli, backendOptions *BackendOptions, lsOpts lsOptions) error {
filters := lsOpts.Filter.Value()
err := filters.Validate(acceptedListFilters)
if err != nil {
return err

for filter := range filters {
if _, ok := acceptedListFilters[filter]; !ok {
return errors.New("invalid filter '" + filter + "'")
}
}

backend, err := compose.NewComposeService(dockerCli, backendOptions.Options...)
Expand All @@ -77,13 +101,12 @@ func runList(ctx context.Context, dockerCli command.Cli, backendOptions *Backend
return err
}

if filters.Len() > 0 {
if len(filters) > 0 {
var filtered []api.Stack
for _, s := range stackList {
if filters.Contains("name") && !filters.Match("name", s.Name) {
continue
if match(filters, "name", s.Name) {
filtered = append(filtered, s)
}
filtered = append(filtered, s)
}
stackList = filtered
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/compose/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func filterByStatus(containers []api.ContainerSummary, statuses []string) []api.

func hasStatus(c api.ContainerSummary, statuses []string) bool {
for _, status := range statuses {
if c.State == status {
if string(c.State) == status {
return true
}
}
Expand Down
13 changes: 6 additions & 7 deletions cmd/compose/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/container"
"github.com/docker/docker/api/types/filters"
"github.com/moby/moby/client"
"github.com/spf13/cobra"

"github.com/docker/compose/v5/pkg/api"
Expand Down Expand Up @@ -67,18 +67,17 @@ func runStats(ctx context.Context, dockerCli command.Cli, opts statsOptions, ser
if err != nil {
return err
}
filter := []filters.KeyValuePair{
filters.Arg("label", fmt.Sprintf("%s=%s", api.ProjectLabel, name)),
}
f := client.Filters{}
f.Add("label", fmt.Sprintf("%s=%s", api.ProjectLabel, name))

if len(service) > 0 {
filter = append(filter, filters.Arg("label", fmt.Sprintf("%s=%s", api.ServiceLabel, service[0])))
f.Add("label", fmt.Sprintf("%s=%s", api.ServiceLabel, service[0]))
}
args := filters.NewArgs(filter...)
return container.RunStats(ctx, dockerCli, &container.StatsOptions{
All: opts.all,
NoStream: opts.noStream,
NoTrunc: opts.noTrunc,
Format: opts.format,
Filters: &args,
Filters: f,
})
}
21 changes: 14 additions & 7 deletions cmd/formatter/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ package formatter

import (
"fmt"
"net/netip"
"strconv"
"strings"
"time"

"github.com/docker/cli/cli/command/formatter"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/go-units"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/client/pkg/stringid"

"github.com/docker/compose/v5/pkg/api"
)
Expand Down Expand Up @@ -197,26 +198,32 @@ func (c *ContainerContext) ExitCode() int {
}

func (c *ContainerContext) State() string {
return c.c.State
return string(c.c.State)
}

func (c *ContainerContext) Status() string {
return c.c.Status
}

func (c *ContainerContext) Health() string {
return c.c.Health
return string(c.c.Health)
}

func (c *ContainerContext) Publishers() api.PortPublishers {
return c.c.Publishers
}

func (c *ContainerContext) Ports() string {
var ports []container.Port
var ports []container.PortSummary
for _, publisher := range c.c.Publishers {
ports = append(ports, container.Port{
IP: publisher.URL,
var pIP netip.Addr
if publisher.URL != "" {
if p, err := netip.ParseAddr(publisher.URL); err == nil {
pIP = p
}
}
ports = append(ports, container.PortSummary{
IP: pIP,
PrivatePort: uint16(publisher.TargetPort),
PublicPort: uint16(publisher.PublishedPort),
Type: publisher.Protocol,
Expand Down
2 changes: 1 addition & 1 deletion cmd/formatter/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

"github.com/buger/goterm"
"github.com/docker/docker/pkg/jsonmessage"
"github.com/moby/moby/client/pkg/jsonmessage"

"github.com/docker/compose/v5/pkg/api"
)
Expand Down
61 changes: 30 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/docker/compose/v5

go 1.24.3
go 1.25.0

require (
github.com/AlecAivazis/survey/v2 v2.3.7
Expand All @@ -14,11 +14,10 @@ require (
github.com/containerd/errdefs v1.0.0
github.com/containerd/platforms v1.0.0-rc.2
github.com/distribution/reference v0.6.0
github.com/docker/buildx v0.30.1
github.com/docker/cli v28.5.2+incompatible
github.com/docker/buildx v0.31.0
github.com/docker/cli v29.2.0+incompatible
github.com/docker/cli-docs-tool v0.11.0
github.com/docker/docker v28.5.2+incompatible
github.com/docker/go-connections v0.6.0
github.com/docker/go-units v0.5.0
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203
github.com/fsnotify/fsevents v0.2.0
Expand All @@ -29,8 +28,10 @@ require (
github.com/jonboulle/clockwork v0.5.0
github.com/mattn/go-shellwords v1.0.12
github.com/mitchellh/go-ps v1.0.0
github.com/moby/buildkit v0.26.3
github.com/moby/go-archive v0.1.0
github.com/moby/buildkit v0.27.0
github.com/moby/go-archive v0.2.0
github.com/moby/moby/api v1.53.0
github.com/moby/moby/client v0.2.2
github.com/moby/patternmatcher v0.6.0
github.com/moby/sys/atomicwriter v0.1.0
github.com/morikuni/aec v1.1.0
Expand Down Expand Up @@ -62,9 +63,7 @@ require (

require (
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/containerd/containerd/api v1.10.0 // indirect
github.com/containerd/continuity v0.4.5 // indirect
github.com/containerd/errdefs/pkg v0.3.0 // indirect
Expand All @@ -74,9 +73,8 @@ require (
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.3 // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/docker-credential-helpers v0.9.5 // indirect
github.com/docker/go-connections v0.6.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
Expand All @@ -87,22 +85,19 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/in-toto/in-toto-golang v0.9.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.18.2 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/capability v0.4.0 // indirect
Expand All @@ -112,24 +107,20 @@ require (
github.com/moby/sys/user v0.4.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/otiai10/mint v1.6.3 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.23.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.66.1 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
github.com/secure-systems-lab/go-securesystemslib v0.9.1 // indirect
github.com/shibumi/go-pathspec v1.3.0 // indirect
github.com/theupdateframework/notary v0.7.0 // indirect
github.com/sigstore/sigstore v1.10.0 // indirect
github.com/sigstore/sigstore-go v1.1.4-0.20251124094504-b5fe07a5a7d7 // indirect
github.com/tonistiigi/dchapes-mode v0.0.0-20250318174251-73d941a28323 // indirect
github.com/tonistiigi/fsutil v0.0.0-20250605211040-586307ad452f // indirect
github.com/tonistiigi/fsutil v0.0.0-20251211185533-a2aa163d723f // indirect
github.com/tonistiigi/go-csvvalue v0.0.0-20240814133006-030d3b2625d0 // indirect
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea // indirect
github.com/tonistiigi/vt100 v0.0.0-20240514184818-90bafcd6abab // indirect
Expand All @@ -142,16 +133,24 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.38.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.1 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/term v0.37.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/crypto v0.46.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/term v0.38.0 // indirect
golang.org/x/text v0.32.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251029180050-ab9386a59fda // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251029180050-ab9386a59fda // indirect
google.golang.org/protobuf v1.36.10 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20251103181224-f26f9409b101 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20251103181224-f26f9409b101 // indirect
google.golang.org/protobuf v1.36.11 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

exclude (
// FIXME(thaJeztah): remove this once kubernetes updated their dependencies to no longer need this.
//
// For additional details, see this PR and links mentioned in that PR:
// https://github.com/kubernetes-sigs/kustomize/pull/5830#issuecomment-2569960859
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2
)
Loading