Compare commits

...

174 Commits

Author SHA1 Message Date
Guillaume Lours
e1fd7a6567 using as flag of the up command, watch was blocking process shutdown
This happened when sunsetting the application from docker compose down command

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-20 10:50:01 +02:00
Joana Hrotko
de478f84b0 Add open watch docs in up menu
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-06-18 16:31:01 +01:00
Guillaume Lours
24a281fa5d bump buildkit to v0.14.0 and buildx to v0.15.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-18 10:52:41 +02:00
Guillaume Lours
54a5e7d4aa stop watch process when associated up process is stopped
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-17 22:59:09 +02:00
dependabot[bot]
36ef5b3881 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 26.1.3+incompatible to 26.1.4+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v26.1.3...v26.1.4)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 21:56:36 +02:00
dependabot[bot]
5694a2b0f8 build(deps): bump github.com/containerd/containerd from 1.7.17 to 1.7.18
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.17 to 1.7.18.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.17...v1.7.18)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 15:04:40 +02:00
dependabot[bot]
695d3419cf build(deps): bump golang.org/x/sys from 0.20.0 to 0.21.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.20.0 to 0.21.0.
- [Commits](https://github.com/golang/sys/compare/v0.20.0...v0.21.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 14:29:32 +02:00
dependabot[bot]
981bcbbe7a build(deps): bump github.com/hashicorp/go-version from 1.6.0 to 1.7.0
Bumps [github.com/hashicorp/go-version](https://github.com/hashicorp/go-version) from 1.6.0 to 1.7.0.
- [Release notes](https://github.com/hashicorp/go-version/releases)
- [Changelog](https://github.com/hashicorp/go-version/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/go-version/compare/v1.6.0...v1.7.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/go-version
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 12:56:46 +02:00
Sebastiaan van Stijn
5ec37d08a5 build: replace uses of archive.CanonicalTarNameForPath
This function is an alias for filepath.IsAbs and we are considering deprecating
and/or removing this function in the archive package, so removing its uses
helps transitioning if we decide to deprecate and/or remove it.

[docker/cli@fb0788f] also added a normalize step in TrimBuildFilesFromExcludes,
so that callers are not _required_ to first normalize the path, so the
normalizeation may be redunant, but keeping the normalization as this variable
is used further down the code.

[docker/cli@fb0788f]: fb0788f18f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 12:00:24 +02:00
Guillaume Lours
1a14fcb1e6 update gh actions versions, update engine matrix, bump golang to 1.21.11
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-12 18:16:29 +02:00
Nicolas De Loof
084a5ca312 enforce keyboard.Close is always executed to restore terminal
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-06-11 07:20:37 +02:00
Nicolas De Loof
d633c33a19 config --environment
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-06-11 06:59:19 +02:00
Alex Bedo
cc09f39f29 Readd event
Signed-off-by: Alex Bedo <alex98hun@gmail.com>
2024-06-10 12:06:30 +02:00
Alex Bedo
918b508bd5 remove unreachable code
if statement is preceded by another that has the same condition and ends with a return

Signed-off-by: Alex Bedo <alex98hun@gmail.com>
2024-06-10 12:06:30 +02:00
Nicolas De Loof
10531f6302 Fix dot env file to define COMPOSE_* variables
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-06-08 14:55:36 +02:00
Guillaume Lours
bf1bd3fc60 return an error when --detach and --watch are used together in up command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-06-07 14:02:45 +02:00
Casey Korver
02f40eea67 Correct 'cancellation' typo in comment
Signed-off-by: Casey Korver <casey@korver.dev>
2024-06-05 09:22:59 +02:00
IDOMATH
250c3112b9 Fix: change append to use slice index in ps.go
Signed-off-by: Blane Tschida <btdothemath@gmail.com>
2024-05-30 16:16:01 +02:00
Nicolas De Loof
495a087fb5 COMPOSE_PROFILES can be set by .env file
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-30 07:40:01 +02:00
Nicolas De Loof
fd1f73a5e7 prevent concurrent map write relying on project immutability
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-29 11:29:18 +02:00
dependabot[bot]
bf1dd0c267 build(deps): bump github.com/containerd/containerd from 1.7.16 to 1.7.17
Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.7.16 to 1.7.17.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](https://github.com/containerd/containerd/compare/v1.7.16...v1.7.17)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-24 10:58:53 +02:00
dependabot[bot]
1cf6dea444 build(deps): bump github.com/docker/buildx from 0.14.0 to 0.14.1
Bumps [github.com/docker/buildx](https://github.com/docker/buildx) from 0.14.0 to 0.14.1.
- [Release notes](https://github.com/docker/buildx/releases)
- [Commits](https://github.com/docker/buildx/compare/v0.14.0...v0.14.1)

---
updated-dependencies:
- dependency-name: github.com/docker/buildx
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-24 10:46:52 +02:00
Nicolas De Loof
1adc4cb16f drop COMPOSE_EXPERIMENTAL_OTEL as docker/cli has opentelemetry in
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-24 10:27:23 +02:00
Guillaume Lours
2ed40e8042 add gui/composeview as part of available commands
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-23 19:19:59 +02:00
Nicolas De Loof
7ad73c2899 fix opentelemetry
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-23 15:58:24 +02:00
Guillaume Lours
2593256985 bump compose-go to version v2.1.1
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-22 12:39:20 +02:00
Rob Murray
048fd136d2 Set endpoint-specific DriverOpts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-22 12:39:20 +02:00
Rob Murray
663866cbe5 Bump compose-go version to latest main
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-22 12:39:20 +02:00
Kirill A. Korinsky
fb25e88a03 Backport OpenBSD patches
Here a trivial patch whcih I've used inside OpenBSD port to build it

Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
2024-05-22 11:35:37 +02:00
Guillaume Lours
3635303372 add new navigation menu to open Compose app configuration in Docker Desktop
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-22 11:34:10 +02:00
dependabot[bot]
2cee028e99 build(deps): bump github.com/fsnotify/fsevents from 0.1.1 to 0.2.0
Bumps [github.com/fsnotify/fsevents](https://github.com/fsnotify/fsevents) from 0.1.1 to 0.2.0.
- [Release notes](https://github.com/fsnotify/fsevents/releases)
- [Commits](https://github.com/fsnotify/fsevents/compare/v0.1.1...v0.2.0)

---
updated-dependencies:
- dependency-name: github.com/fsnotify/fsevents
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-22 11:26:41 +02:00
dependabot[bot]
c78f84aeb5 build(deps): bump golang.org/x/sys from 0.19.0 to 0.20.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.19.0 to 0.20.0.
- [Commits](https://github.com/golang/sys/compare/v0.19.0...v0.20.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-22 11:15:08 +02:00
Nicolas De Loof
5c6924ec6f fix --resolve-image-digests
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-22 10:54:55 +02:00
Nicolas De Loof
9e8c8caa2b allow a local .env file to override compose.yaml sibling .env
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-21 16:01:29 +02:00
Guillaume Lours
da8189cf22 Bump docker engine and cli to version 26.1.3
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-05-17 13:18:14 +02:00
Guillaume Lours
eb5e018698 Merge pull request #11811 from ndeloof/bump_docker_v26.1.2
Bump docker to v26.1.2
2024-05-13 11:51:30 +02:00
Nicolas De Loof
e64b96d0fa Bump docker to v26.1.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-13 08:54:56 +02:00
Joana Hrotko
b81624185f Add documentation for --menu up option and COMPOSE_MENU environemnt variable
Co-authored-by: Milas Bowman <devnull@milas.dev>
Signed-off-by: Joana H <joana.hrotko@gmail.com>
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-05-07 15:37:32 +02:00
Nicolas De loof
591d9eb3a2 chore(deps): bump docker to v26.1.1 (#11794)
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-05-06 09:16:01 -04:00
Joana H
9c0b922597 fix: overlapping logs and menu navigation (#11765) 2024-04-24 14:59:42 -04:00
Guillaume Lours
c26d2fa7cf Merge pull request #11762 from docker/dependabot/go_modules/github.com/moby/buildkit-0.13.1
build(deps): bump github.com/moby/buildkit from 0.13.0-rc3.0.20240417151852-71f99c52a669 to 0.13.1
2024-04-24 19:27:31 +02:00
dependabot[bot]
cfb110653f build(deps): bump github.com/moby/buildkit
Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.13.0-rc3.0.20240417151852-71f99c52a669 to 0.13.1.
- [Release notes](https://github.com/moby/buildkit/releases)
- [Commits](https://github.com/moby/buildkit/commits/v0.13.1)

---
updated-dependencies:
- dependency-name: github.com/moby/buildkit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-24 17:32:50 +02:00
Guillaume Lours
b53b8b24f1 Merge pull request #11739 from milas/fix-e2e-cascade-flaky
chore(e2e): fix flaky cascade failure test
2024-04-24 16:29:51 +02:00
Milas Bowman
36bf0c458b chore(e2e): fix flaky cascade failure test
This was racy with the sleep, so the Compose file has been
tweaked to make it pass reliably.

Now, there's 3 services:
 * `running` - sleeps forever
 * `exit` - exits _successfully_ immediately
   * depends on `running` started
 * `fail` - exits _with error_ immediately
   * depends on `exit` succeeding

Now, the test can ensure that the containers are all run/
started in the expected order the assertions will be reliable.

Before, it was possible for `fail` to run & exit before `exit`,
for example. The `running` service also ensures there's always
at least one other "running" container when we do an abort.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-04-24 11:03:27 +02:00
Guillaume Lours
299fcd57fd use v2.26.1 tag for moby and Docker cli
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-04-24 10:57:11 +02:00
Milas Bowman
b90cb48a1d chore(deps): update to Moby v26.1 & buildx v0.14
* `moby/buildkit` commit comes from `docker/buildx`
* v26.1-dev from `moby/moby` & `docker/cli`

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-04-24 10:57:11 +02:00
Guillaume Lours
f8808d81c5 bump compose-go version to v2.1.0
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-04-23 10:35:16 +02:00
Guillaume Lours
2c9c60e007 Merge pull request #11752 from ndeloof/flag_equal
fix support for `--flag=value` syntax in compatibility mode
2024-04-22 10:52:59 +02:00
Nicolas De Loof
9970a84ae6 fix support for --context=foo
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-22 10:42:34 +02:00
Jaime Soriano Pastor
5682480726 Fix #11710: Avoid to try to close channel twice after hitting Ctrl-C on compose up (#11719)
Ensure done channel is closed only once

Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-20 06:09:26 +00:00
Milas Bowman
fd532a37e7 fix(desktop): remove overly-aggressive feature flag check (#11748) 2024-04-19 16:06:57 -04:00
racequite
2aa568ceba chore: fix typo in comment
Signed-off-by: racequite <quiterace@gmail.com>
2024-04-19 09:54:08 +02:00
Nicolas De Loof
4ae2e0ec55 bump dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-18 10:58:56 +02:00
Milas Bowman
922422a539 fix: do not try to create file shares for non-directories
When creating automatic file shares, ignore any non-directory
bind mounts, e.g. for an individual (normal) file or a special
type like a Unix socket (`/var/run/docker.sock`).

Additionally, there's no need to create a directory if one
does not exist, the API will handle that. However, the check
for existence remains so that `create_host_path: false`
mounts can be ignored.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-04-17 17:12:03 +02:00
Nicolas De Loof
d239f0f318 check container_name is not in use by another service we will create
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-16 17:26:50 +02:00
Nicolas De Loof
ca734ce565 don't clear line when navigation is disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-16 16:04:23 +02:00
Nicolas De loof
c9e070f0f6 fix: return correct exit code with --exit-code-from (#11715) 2024-04-16 09:44:23 -04:00
Nicolas De Loof
b3792dd258 progress for resource can be restarted after more Working event comes
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-15 22:05:46 +02:00
Nicolas De Loof
d8ee474e09 Revert "Stop the resource timer after last expected event"
This reverts commit a4ddbcb6b2.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-15 22:05:46 +02:00
Jaime Soriano Pastor
7d3616474d Revert change to allow trying to kill again if a kill fails
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Jaime Soriano Pastor
6a3501f901 Handle errors and allow to send multiple kills if one failed
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Jaime Soriano Pastor
5daed33c6a Ignore errors when killing on second Ctrl-C
Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Jaime Soriano Pastor
5c1e5f3fc7 docker compose up always kills the containers on second Ctrl-C
Kill executed on the second Ctrl-C of docker compose up  was
filtering containers depending on its state. In some cases the
containers can reach an state for what these filters don't get
any container, and the command keeps reporting `no container to
kill`.

Remove this filtering, so it tries to kill any container it
finds, independently of its state.

Fixes https://github.com/docker/compose/issues/10661

Signed-off-by: Jaime Soriano Pastor <jaime.soriano@elastic.co>
2024-04-14 17:44:39 +02:00
Nicolas De Loof
b032999f06 read COMPOSE_REMOVE_ORPHANS from .env
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-11 16:24:15 +02:00
koooge
5059a1d7bf Set Required false to depends_on containers for compose -p stop/down
Signed-off-by: koooge <koooooge@gmail.com>
2024-04-11 10:48:09 +02:00
koooge
54a525bbe6 Ignore missing containers when compose stop -p
Signed-off-by: koooge <koooooge@gmail.com>
2024-04-11 10:48:09 +02:00
koooge
8ceaf49296 Ignore missing containers when compose down -p
Signed-off-by: koooge <koooooge@gmail.com>
2024-04-11 10:48:09 +02:00
Guillaume Lours
bfee07e1eb Merge pull request #11708 from ndeloof/entitlements
Introduce support for build.entitlements
2024-04-10 14:16:30 +02:00
Nicolas De Loof
1d32592056 Introduce support for build.entitlements
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-10 12:27:49 +02:00
Delath
85567ae092 Remove dead url reference.
Signed-off-by: Delath <62723360+delath@users.noreply.github.com>
2024-04-09 17:50:24 +02:00
Nicolas De Loof
b4280fb561 e2e test for --all-resources
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-09 15:30:42 +02:00
Nicolas De Loof
865a64afea introduce --all-resources to _not_ exclude resources not used by services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-09 15:30:42 +02:00
Nicolas De Loof
29692b5921 Introduce --abort-on-container-failure
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-08 15:40:54 +02:00
Guillaume Lours
2658c372a7 bump golang version to 1.21.9
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-04-04 13:36:48 +02:00
Nicolas De Loof
d71d8bce24 don't use ansi espace sequence when disabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-04-03 15:43:16 +02:00
Joana Hrotko
ff20b641c7 Does not start keyboard manager if there is no tty
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-28 17:57:26 +00:00
Joana Hrotko
339b331a86 Change menu information text to dim
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-28 12:18:00 +00:00
Guillaume Lours
6fe69b2575 Merge pull request #11664 from jhrotko/fix-no-build-watch
Handle --no-build and --watch args
2024-03-27 11:37:38 +01:00
Joana Hrotko
dd5614ec3b Handle --no-build and --watch args
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-26 18:22:26 +00:00
dependabot[bot]
4b7b6adc76 build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc6 to 1.1.0.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0-rc6...v1.1.0)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-26 15:24:39 +01:00
Felix Fontein
466374bdd0 Unwrap error message.
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-03-25 07:37:34 +01:00
Felix Fontein
2e85b3c265 Include error message in pull warning/errors
Signed-off-by: Felix Fontein <felix@fontein.de>
2024-03-25 07:37:34 +01:00
Milas Bowman
3371227794 chore(desktop): revised feature detection for file shares
Unfortunately, the feature flag mechanism for experimental features
isn't adequate. To avoid some edge cases where Compose might try to
use Synchronized file shares with Desktop when the feature isn't
available, we need to query a new endpoint.

Before we move any of this out of experimental, we need to improve
the integration here with Desktop & Compose so that we get all the
necessary feature/experiment state up-front to reduce the quantity
of IPC calls needed up-front.

For now, there's some intentional redundancy to avoid making this
extra call if we can avoid it. The actual endpoint is very cheap/
fast, but every IPC call is a potential point of of failure, so
it's worth it.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-03-22 18:16:27 +01:00
Joana Hrotko
e9dc82011f Add Navigation Menu to compose up
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-22 17:48:25 +01:00
Nicolas De Loof
3950460703 Add support for volume Subpath option
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 14:33:56 +01:00
Nicolas De Loof
3b541b071c Bump docker v26.0.0
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 14:33:56 +01:00
Nicolas De Loof
25671ae622 introduce config --variables to list compose model variables
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 13:51:30 +01:00
Sebastian Correa
0191e69d5b Fix docs on default build image name
150fd4b8cf changed the default separator from _ to -, but the docker compose build docs still mention _.

Signed-off-by: Sebastian Correa <43179146+sebastian-correa@users.noreply.github.com>
2024-03-22 13:42:13 +01:00
Nicolas De Loof
897d239fcb Bump compose-go to v2.0.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 11:21:14 +01:00
Nicolas De Loof
c5a760ce43 add support for annotations
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-22 10:45:44 +01:00
Joana H
759d3bc9f9 Merge pull request #11647 from milas/revert-compose-go-201
chore(deps): revert "Bump compose-go to v2.0.1"
2024-03-21 18:00:34 +00:00
Milas Bowman
26f687a12b Revert "Bump compose-go to v2.0.1"
This reverts commit ad41461309.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-03-21 13:43:44 -04:00
Nicolas De Loof
ad41461309 Bump compose-go to v2.0.1
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-21 15:54:41 +01:00
Milas Bowman
db4ed89528 feat(desktop): synchronized file share integration (#11614) 2024-03-20 14:41:24 -04:00
Milas Bowman
1b5fa3b93f feat(experiments): add experimental feature state (#11633)
Use environment variable for global opt-out and Docker Desktop (if
available) to determine specific experiment states.

In the future, we'll allow per-feature opt-in/opt-out via env vars
as well, but currently there is a single `COMPOSE_EXPERIMENTAL` env
var that can be used to opt-out of all experimental features
independently of Docker Desktop configuration.
2024-03-20 13:44:27 +00:00
Guillaume Lours
86cd52370a Merge pull request #11630 from ndeloof/config_json
fix `compose config --format json`
2024-03-18 16:11:18 +01:00
Guillaume Lours
4f97edf355 reduce timeout of the Otel tracing command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-03-18 08:40:36 +01:00
Nicolas De Loof
bc5fc6ba7e fix compose config --format json
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-18 08:09:54 +01:00
Nicolas De Loof
f937e42aaf Bump compose-go v2.0.0
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-15 13:02:46 +01:00
Andrew Onyshchuk
f46ca459d2 services shell completion bugfix
Signed-off-by: Andrew Onyshchuk <andryk.rv@gmail.com>
2024-03-15 10:47:30 +01:00
Nicolas De Loof
b2d4c1b865 fix TestBuildPlatformsWithCorrectBuildxConfig
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-15 10:38:03 +01:00
Nicolas De Loof
5a1ba0efcf only use ToModel when --no-interpolate is set
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-13 06:48:24 +01:00
Milas Bowman
17d4229e57 feat(desktop): add Docker Desktop detection and client skeleton (#11593) 2024-03-12 09:47:41 -04:00
Milas Bowman
4efb89709c chore(deps): upgrade go to 1.21.8 (#11578) 2024-03-05 22:23:52 +01:00
Milas Bowman
f35449a603 ci(deps): bump moby/moby & docker/cli to v25.0.4 (#11566) 2024-03-05 20:39:18 +00:00
Joana Hrotko
34b11c4f4f Add test summary for test jobs in ci
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-03-01 13:32:04 +01:00
Guillaume Lours
a7acf5fa67 Merge pull request #11535 from ndeloof/simpler
make code simpler
2024-03-01 10:02:12 +01:00
Nicolas De Loof
c525373acb make code simpler
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-03-01 09:55:03 +01:00
Nicolas De Loof
e99b8acea7 avoid duplicated "xx exited with code 0" message
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-29 13:57:17 +01:00
Nicolas De Loof
8ab8df86e0 introduce --watch
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 19:04:58 +01:00
Nicolas De Loof
de178267df move code into small functions for better readability
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 18:54:43 +01:00
Nicolas De Loof
1680f9a874 restore support for config --no-interpolate
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-28 18:54:43 +01:00
Joana Hrotko
5c4f33702e remove docker cli step in ci.yml
Signed-off-by: Joana Hrotko <joana.hrotko@docker.com>
2024-02-27 12:50:44 +01:00
Joana H
e2762b144e Merge pull request #11542 from ndeloof/log_attach
get log to manage `attach`
2024-02-27 11:04:46 +00:00
Nicolas De Loof
58ec0e9fb6 get log to manage attach
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-22 18:27:05 +01:00
Guillaume Lours
a7224411b4 Merge pull request #11513 from glours/use-go-ps-pid-lock
Double check watch pid if detected as still running on Windows
2024-02-22 16:21:47 +01:00
Guillaume Lours
c5a88deeba Merge pull request #11536 from glours/bump-compose-go-2.0.0-rc.8
bump compose-go to version v2.0.0-rc.8
2024-02-21 19:57:19 +01:00
Guillaume Lours
349d9f34d0 bump compose-go to version v2.0.0-rc.8
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-21 19:41:04 +01:00
Guillaume Lours
9d38ee1726 Merge pull request #11537 from glours/fix-flakyness-run-quiet-pull
use a dedicated compose file for --quiet-pull e2e test
2024-02-21 19:40:01 +01:00
Guillaume Lours
697a48af32 use an dedicated compose file --quiet-pull e2e test
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-21 18:59:09 +01:00
Guillaume Lours
9b0d1ffcf8 Add a fallback check of Watch pid on Windows
False positives were detected when checking the previous watch process state

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-19 15:01:38 +01:00
Guillaume Lours
d10a179f3e add support of QuietOption to create command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-19 14:19:01 +01:00
Guillaume Lours
94246f3cac pass QuietOption when starting dependencies from run command
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-02-19 14:19:01 +01:00
Nicolas De Loof
9630cc5808 when ran with ANSI disabled, force progress=plain
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-18 12:33:20 +01:00
Gautham Hullikunte
6c175548b8 Issue-11374: Modified compose up command to respect COMPOSE_REMOVE_ORPHANS environment variable
Signed-off-by: Gautham Hullikunte <46633282+batcity@users.noreply.github.com>
Signed-off-by: Gautham Hullikunte <gautham@Gauthams-MacBook-Pro.local>
2024-02-17 09:37:00 +01:00
Guillaume Lours
f1431b2a48 Merge pull request #11512 from laurazard/bump-engine-ci
ci: bump engine version to `25.0.3`
2024-02-16 15:03:09 +01:00
Laura Brehm
9b0e3d53eb ci: bump engine version to 25.0.3
changes: https://github.com/moby/moby/releases/tag/v25.0.3

(Hopefully, this fixes some networking flakyness)

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-02-16 12:47:24 +00:00
Nicolas De Loof
de3da829ea sort containers to optimize scale down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-15 17:47:42 +01:00
Nicolas De Loof
c79aabde32 discard stdout for laaarge log test
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-15 16:18:58 +01:00
Guillaume Lours
eb5f7d76fe Merge pull request #11503 from ndeloof/includes_metric
use listeners to collect include metrics
2024-02-15 11:27:19 +01:00
Nicolas De Loof
0aad322140 use listeners to collect include metrics
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-15 11:20:09 +01:00
David Karlsson
b1c06770d4 docs: update cli reference link
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-02-15 08:20:11 +01:00
Guillaume Lours
a220043ca0 Merge pull request #11497 from milas/rm-docker-cp-syncer
chore(watch): remove old `docker cp` implementation
2024-02-14 21:26:05 +01:00
Piotr Dąbrowski
e330f5905b docs: unify no trailing dots in docstrings and help (#11301) 2024-02-14 14:02:37 -05:00
Guillaume Lours
aa56ab3e71 Merge pull request #11492 from jhrotko/use-listeners-for-file-metadata
Use listener for file metadata
2024-02-14 18:04:06 +01:00
jhrotko
16c8099cf8 Use listener for file metadata
Signed-off-by: jhrotko <joana.hrotko@docker.com>
2024-02-14 16:51:56 +00:00
Nicolas De Loof
07bda5960e fix deadlock collecting large logs
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-13 20:15:19 +01:00
Milas Bowman
d203402998 chore(watch): remove old docker cp implementation
This has not been the default for quite a while and required
setting an environment variable to revert back.

The tar implementation is more performant and addresses several
edge cases with the original `docker cp` version, so it's time
to fully retire it.

The scaffolding for multiple sync implementations remains to
support future experimentation here.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-02-13 12:56:53 -05:00
Nicolas De loof
894ab41c3b ci(deps): bump docker/cli to v25.0.3 (#11481)
https://github.com/docker/cli/releases/tag/v25.0.3
https://github.com/moby/moby/releases/tag/v25.0.3
2024-02-12 11:20:31 -05:00
1arp
3ba66453d2 pass All option to backend api.Service when length statuses is not equal to zero
Signed-off-by: 1arp <dekhijaegi@gmail.com>
2024-02-09 16:37:29 +01:00
Guillaume Lours
4ce63f53f7 Merge pull request #11485 from jhrotko/add-otel-build-depends-capabilities
add OTEL build,depends and capabilities to attributes
2024-02-09 12:25:07 +01:00
jhrotko
2eca9313c2 Add OTEL specs: build, depends_on, capabilities (gpu/tpu)
Signed-off-by: jhrotko <joana.hrotko@docker.com>
2024-02-09 10:55:07 +00:00
dependabot[bot]
1fea7c1beb build(deps): bump github.com/opencontainers/image-spec
Bumps [github.com/opencontainers/image-spec](https://github.com/opencontainers/image-spec) from 1.1.0-rc5 to 1.1.0-rc6.
- [Release notes](https://github.com/opencontainers/image-spec/releases)
- [Changelog](https://github.com/opencontainers/image-spec/blob/main/RELEASES.md)
- [Commits](https://github.com/opencontainers/image-spec/compare/v1.1.0-rc5...v1.1.0-rc6)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/image-spec
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-08 15:47:39 +01:00
Milas Bowman
acf2ffb0c7 feat(tracing): add project hash attr
Hash the project config and add it as an attribute. This can be
used to group multiple spans.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-02-08 15:47:25 +01:00
Milas Bowman
0d48a93f57 chore(load): ensure context passed to load
This wasn't always getting passed, so adding it to the wrapper
function where it'll pass the `WithContext()` loader method at
the last moment.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2024-02-08 15:46:37 +01:00
Laura Brehm
aaa7ef6de5 Include all networks in ContainerCreate call if API >= 1.44
Previously, we included the container's primary network in the
ContainerCreate API call, and then connected the created container
to each extra network one-by-one, by calling NetworkConnect.

However, starting API version 1.44, the ContainerCreate endpoint now
takes multiple EndpointsConfigs, allowing us to just include all the
network configurations there and skip connecting the container to each
extra network separately.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-02-07 16:21:15 +01:00
Nicolas De Loof
6ef55a531f bump compose-go to v2.0.0-rc.4
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-07 10:44:44 +01:00
Nicolas De Loof
a553db33c6 CI: docker engine version matrix
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-02-05 12:09:45 +01:00
Guillaume Lours
338ffe07a0 Merge pull request #11443 from docker/dependabot/go_modules/github.com/docker/cli-25.0.2incompatible
build(deps): bump github.com/docker/cli from 25.0.1+incompatible to 25.0.2+incompatible
2024-02-01 12:03:18 +01:00
dependabot[bot]
05bec55d21 build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 25.0.1+incompatible to 25.0.2+incompatible.
- [Commits](https://github.com/docker/cli/compare/v25.0.1...v25.0.2)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-01 09:44:43 +00:00
Guillaume Lours
3c25af4fe9 Merge pull request #11405 from ndeloof/issue_11392
Fix load .env from project directory when project file is set by COMPOSE_FILE
2024-01-31 10:52:28 +01:00
Milas Bowman
8fdd45cd4c chore(e2e): fix flaky test & standalone behavior (#11382) 2024-01-30 10:49:53 -05:00
CrazyMax
a0954dc59d ci(deps): replace buildkit to fix fsutil issues on Windows (#11426) 2024-01-30 10:48:48 -05:00
jhrotko
0582001810 Fix canonical container name
Signed-off-by: jhrotko <joana.hrotko@docker.com>
2024-01-30 15:12:22 +01:00
Guillaume Lours
ac8ea082a1 Merge pull request #11409 from ndeloof/swarm_overlay_network
don't check external network existence when swarm is enabled
2024-01-29 20:11:13 +01:00
Nicolas De Loof
da1a34a8f2 don't check external network existence when swarm is enabled
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-29 20:00:29 +01:00
Guillaume Lours
cdb6eb55d5 Merge pull request #11406 from docker/dependabot/go_modules/github.com/docker/cli-25.0.1incompatible
build(deps): bump github.com/docker/cli from 25.0.0+incompatible to 25.0.1+incompatible
2024-01-29 19:56:56 +01:00
dependabot[bot]
8b023ae07d build(deps): bump github.com/docker/cli
Bumps [github.com/docker/cli](https://github.com/docker/cli) from 25.0.0+incompatible to 25.0.1+incompatible.
- [Commits](https://github.com/docker/cli/compare/v25.0.0...v25.0.1)

---
updated-dependencies:
- dependency-name: github.com/docker/cli
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 19:46:03 +01:00
Guillaume Lours
e08140babe Merge pull request #11407 from docker/dependabot/go_modules/github.com/docker/docker-25.0.1incompatible
build(deps): bump github.com/docker/docker from 25.0.0+incompatible to 25.0.1+incompatible
2024-01-29 19:44:44 +01:00
dependabot[bot]
8c80297c76 build(deps): bump github.com/docker/docker
Bumps [github.com/docker/docker](https://github.com/docker/docker) from 25.0.0+incompatible to 25.0.1+incompatible.
- [Release notes](https://github.com/docker/docker/releases)
- [Commits](https://github.com/docker/docker/compare/v25.0.0...v25.0.1)

---
updated-dependencies:
- dependency-name: github.com/docker/docker
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 19:33:58 +01:00
Guillaume Lours
05f1472f6a Merge pull request #11422 from ndeloof/storage_opts
Add support for storage_opt
2024-01-29 19:33:22 +01:00
Guillaume Lours
5728c43db8 Merge pull request #11410 from thaJeztah/bump_engine_25.0.1
ci(deps): update DOCKER_CLI_VERSION to v25.0.1
2024-01-29 19:31:45 +01:00
Nicolas De Loof
7e991515bc Add support for storage_opt
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-29 19:24:23 +01:00
Sebastiaan van Stijn
d979115692 ci(deps): update DOCKER_CLI_VERSION to v25.0.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-29 19:23:26 +01:00
Guillaume Lours
c653ddf439 Merge pull request #11411 from laurazard/update-maintainers
Update MAINTAINERS file
2024-01-29 19:22:49 +01:00
Guillaume Lours
a9cbb0f481 Merge pull request #11416 from glours/fix-merge-compose-go-issue
bump compose-go to fix multiple compose files merge issues
2024-01-29 15:41:24 +01:00
Guillaume Lours
71bebc16ee bump compose-go to v2.0.0-rc.3 which fixes multiple compose files merge issues
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-29 15:26:26 +01:00
Guillaume Lours
b0dc374abc Merge pull request #11415 from dvdksn/bump-artifact-upload-v4
build(deps): bump actions/upload-artifact from v3 to v4
2024-01-26 09:49:48 +01:00
David Karlsson
25d16d1fb4 build(deps): bump actions/upload-artifact from v3 to v4
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-01-26 09:39:24 +01:00
Laura Brehm
ab97dcc7c5 update MAINTAINERS file
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-01-25 14:28:44 +00:00
Nicolas De Loof
a8bd3b7af1 Fix load .env from project directory when project file is set by COMPOSE_FILE
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-25 09:26:22 +01:00
Guillaume Lours
bef8785fc2 Merge pull request #11400 from glours/fix-fsutils-windows
use a custom version of fsutils that fixes a bug on Windows causing all Compose builds to fail
2024-01-24 18:39:58 +01:00
Guillaume Lours
811364b4f8 use a custom version of fsutils that fixes a bug on Windows causing all Compose builds to fail
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2024-01-24 17:59:13 +01:00
Nicolas De Loof
1551fcb4e6 introduce stopAndRemoveContainer to share logic scaling down
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2024-01-23 14:16:13 +01:00
201 changed files with 4835 additions and 1932 deletions

View File

@@ -18,9 +18,6 @@ on:
required: false
default: "false"
env:
DOCKER_CLI_VERSION: "25.0.0"
permissions:
contents: read # to fetch code (actions/checkout)
@@ -32,7 +29,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Create matrix
id: platforms
@@ -56,7 +53,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
@@ -81,7 +78,7 @@ jobs:
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
@@ -99,10 +96,10 @@ jobs:
*.cache-to=type=gha,scope=binary-${{ env.PLATFORM_PAIR }},mode=max
-
name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: compose
path: ./bin/release/*
name: compose-${{ env.PLATFORM_PAIR }}
path: ./bin/release
if-no-files-found: error
test:
@@ -110,7 +107,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
@@ -124,12 +121,17 @@ jobs:
*.cache-to=type=gha,scope=test
-
name: Gather coverage data
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-data-unit
path: bin/coverage/unit/
if-no-files-found: error
-
name: Unit Test Summary
uses: test-summary/action@v2
with:
paths: bin/coverage/unit/report.xml
if: always()
e2e:
runs-on: ubuntu-latest
strategy:
@@ -138,25 +140,38 @@ jobs:
mode:
- plugin
- standalone
engine:
- 24.0.9
- 25.0.5
- 26.1.4
steps:
- name: Prepare
run: |
mode=${{ matrix.mode }}
engine=${{ matrix.engine }}
echo "MODE_ENGINE_PAIR=${mode}-${engine}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install Docker ${{ matrix.engine }}
run: |
sudo systemctl stop docker.service
sudo apt-get purge docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-ce-rootless-extras docker-buildx-plugin
sudo apt-get install curl
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --version ${{ matrix.engine }}
- name: Check Docker Version
run: docker --version
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
cache: true
-
name: Setup docker CLI
run: |
curl https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_CLI_VERSION}.tgz | tar xz
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
-
name: Build
uses: docker/bake-action@v2
@@ -185,9 +200,9 @@ jobs:
-
name: Gather coverage data
if: ${{ matrix.mode == 'plugin' }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-data-e2e
name: coverage-data-e2e-${{ env.MODE_ENGINE_PAIR }}
path: bin/coverage/e2e/
if-no-files-found: error
-
@@ -197,36 +212,43 @@ jobs:
rm -f /usr/local/bin/docker-compose
cp bin/build/docker-compose /usr/local/bin
make e2e-compose-standalone
-
name: e2e Test Summary
uses: test-summary/action@v2
with:
paths: /tmp/report/report.xml
if: always()
coverage:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
needs:
- test
- e2e
steps:
# codecov won't process the report without the source code available
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
check-latest: true
- name: Download unit test coverage
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage-data-unit
path: coverage/unit
merge-multiple: true
- name: Download E2E test coverage
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage-data-e2e
pattern: coverage-data-e2e-*
path: coverage/e2e
merge-multiple: true
- name: Merge coverage reports
run: |
go tool covdata textfmt -i=./coverage/unit,./coverage/e2e -o ./coverage.txt
- name: Store coverage report in GitHub Actions
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: go-covdata-txt
path: ./coverage.txt
@@ -246,16 +268,17 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Download artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: compose
path: bin/release
pattern: compose-*
path: ./bin/release
merge-multiple: true
-
name: Create checksums
working-directory: bin/release
working-directory: ./bin/release
run: |
find . -type f -print0 | sort -z | xargs -r0 shasum -a 256 -b | sed 's# \*\./# *#' > $RUNNER_TEMP/checksums.txt
shasum -a 256 -U -c $RUNNER_TEMP/checksums.txt
@@ -263,11 +286,11 @@ jobs:
cat checksums.txt | while read sum file; do echo "$sum $file" > ${file#\*}.sha256; done
-
name: License
run: cp packaging/* bin/release/
run: cp packaging/* ./bin/release/
-
name: List artifacts
run: |
tree -nh bin/release
tree -nh ./bin/release
-
name: Check artifacts
run: |
@@ -277,7 +300,7 @@ jobs:
if: startsWith(github.ref, 'refs/tags/v')
uses: ncipollo/release-action@58ae73b360456532aafd58ee170c045abbeaee37 # v1.10.0
with:
artifacts: bin/release/*
artifacts: ./bin/release/*
generateReleaseNotes: true
draft: true
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@v4
-
name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true

View File

@@ -21,21 +21,21 @@ on:
jobs:
docs-yaml:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Upload reference YAML docs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: docs-yaml
path: docs/reference
retention-days: 1
validate:
uses: docker/docs/.github/workflows/validate-upstream.yml@main
uses: docker/docs/.github/workflows/validate-upstream.yml@919a9b9104a34a40b30d116529bcce589a544d1c # pin for artifact v4 support: https://github.com/docker/docs/pull/19220
needs:
- docs-yaml
with:

View File

@@ -31,9 +31,9 @@ jobs:
env:
GO111MODULE: "on"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
@@ -81,7 +81,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2

View File

@@ -85,8 +85,7 @@ before anybody starts working on it.
We are always thrilled to receive pull requests. We do our best to process them
quickly. If your pull request is not accepted on the first try,
don't get discouraged! Our contributor's guide explains
[the review process we use for simple changes](https://docs.docker.com/opensource/workflow/make-a-contribution/).
don't get discouraged!
### Talking to other Docker users and contributors

View File

@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
ARG GO_VERSION=1.21.6
ARG GO_VERSION=1.21.11
ARG XX_VERSION=1.2.1
ARG GOLANGCI_LINT_VERSION=v1.55.2
ARG ADDLICENSE_VERSION=v1.0.0
@@ -101,16 +101,20 @@ RUN --mount=type=bind,target=. \
FROM build-base AS test
ARG CGO_ENABLED=0
ARG BUILD_TAGS
ENV COMPOSE_MENU=FALSE
RUN --mount=type=bind,target=. \
--mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/go/pkg/mod \
rm -rf /tmp/coverage && \
mkdir -p /tmp/coverage && \
go test -tags "$BUILD_TAGS" -v -cover -covermode=atomic $(go list $(TAGS) ./... | grep -vE 'e2e') -args -test.gocoverdir="/tmp/coverage" && \
rm -rf /tmp/report && \
mkdir -p /tmp/report && \
go run gotest.tools/gotestsum@latest --format testname --junitfile "/tmp/report/report.xml" -- -tags "$BUILD_TAGS" -v -cover -covermode=atomic $(go list $(TAGS) ./... | grep -vE 'e2e') -args -test.gocoverdir="/tmp/coverage" && \
go tool covdata percent -i=/tmp/coverage
FROM scratch AS test-coverage
COPY --from=test --link /tmp/coverage /
COPY --from=test --link /tmp/report /
FROM base AS license-set
ARG LICENSE_FILES

View File

@@ -24,7 +24,6 @@
people = [
"glours",
"milas",
"laurazard",
"ndeloof",
"nicksieger",
"StefanScherer",
@@ -39,6 +38,7 @@
"aiordache",
"chris-crone",
"gtardif",
"laurazard",
"maxcleme",
"rumpl",
"thaJeztah"

View File

@@ -13,6 +13,7 @@
# limitations under the License.
PKG := github.com/docker/compose/v2
export COMPOSE_MENU = FALSE
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
GO_LDFLAGS ?= -w -X ${PKG}/internal.Version=${VERSION}
@@ -75,11 +76,11 @@ install: binary
.PHONY: e2e-compose
e2e-compose: ## Run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
go test -v $(TEST_FLAGS) -count=1 ./pkg/e2e
go run gotest.tools/gotestsum@latest --format testname --junitfile "/tmp/report/report.xml" -- -v $(TEST_FLAGS) -count=1 ./pkg/e2e
.PHONY: e2e-compose-standalone
e2e-compose-standalone: ## Run End to end local tests in standalone mode. Set E2E_TEST=TestName to run a single test
go test $(TEST_FLAGS) -v -count=1 -parallel=1 --tags=standalone ./pkg/e2e
go run gotest.tools/gotestsum@latest --format testname --junitfile "/tmp/report/report.xml" -- $(TEST_FLAGS) -v -count=1 -parallel=1 --tags=standalone ./pkg/e2e
.PHONY: build-and-e2e-compose
build-and-e2e-compose: build e2e-compose ## Compile the compose cli-plugin and run end to end local tests in plugin mode. Set E2E_TEST=TestName to run a single test
@@ -89,7 +90,7 @@ build-and-e2e-compose-standalone: build e2e-compose-standalone ## Compile the co
.PHONY: mocks
mocks:
mockgen --version >/dev/null 2>&1 || go install go.uber.org/mock/mockgen@v0.3.0
mockgen --version >/dev/null 2>&1 || go install go.uber.org/mock/mockgen@v0.4.0
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_compose_api.go -package mocks -source=./pkg/api/api.go Service

View File

@@ -30,6 +30,7 @@ import (
"github.com/docker/compose/v2/internal/tracing"
"github.com/spf13/cobra"
flag "github.com/spf13/pflag"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
@@ -50,7 +51,7 @@ func Setup(cmd *cobra.Command, dockerCli command.Cli, args []string) error {
}
ctx := cmd.Context()
ctx, cmdSpan := tracing.Tracer.Start(
ctx, cmdSpan := otel.Tracer("").Start(
ctx,
"cli/"+strings.Join(commandName(cmd), "-"),
)
@@ -104,7 +105,7 @@ func wrapRunE(c *cobra.Command, cmdSpan trace.Span, tracingShutdown tracing.Shut
if tracingShutdown != nil {
// use background for root context because the cmd's context might have
// been canceled already
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
// TODO(milas): add an env var to enable logging from the
// OTel components for debugging purposes

View File

@@ -19,6 +19,7 @@ package compatibility
import (
"fmt"
"os"
"strings"
"github.com/docker/compose/v2/cmd/compose"
)
@@ -55,6 +56,7 @@ func Convert(args []string) []string {
var rootFlags []string
command := []string{compose.PluginName}
l := len(args)
ARGS:
for i := 0; i < l; i++ {
arg := args[i]
if contains(getCompletionCommands(), arg) {
@@ -81,14 +83,23 @@ func Convert(args []string) []string {
rootFlags = append(rootFlags, arg)
continue
}
if contains(getStringFlags(), arg) {
i++
if i >= l {
fmt.Fprintf(os.Stderr, "flag needs an argument: '%s'\n", arg)
os.Exit(1)
for _, flag := range getStringFlags() {
if arg == flag {
i++
if i >= l {
fmt.Fprintf(os.Stderr, "flag needs an argument: '%s'\n", arg)
os.Exit(1)
}
rootFlags = append(rootFlags, arg, args[i])
continue ARGS
}
if strings.HasPrefix(arg, flag) {
_, val, found := strings.Cut(arg, "=")
if found {
rootFlags = append(rootFlags, flag, val)
continue ARGS
}
}
rootFlags = append(rootFlags, arg, args[i])
continue
}
command = append(command, arg)
}

View File

@@ -38,6 +38,11 @@ func Test_convert(t *testing.T) {
args: []string{"--context", "foo", "-f", "compose.yaml", "up"},
want: []string{"--context", "foo", "compose", "-f", "compose.yaml", "up"},
},
{
name: "with context arg",
args: []string{"--context=foo", "-f", "compose.yaml", "up"},
want: []string{"--context", "foo", "compose", "-f", "compose.yaml", "up"},
},
{
name: "with host",
args: []string{"--host", "tcp://1.2.3.4", "up"},

View File

@@ -43,7 +43,7 @@ func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}
runCmd := &cobra.Command{
Use: "attach [OPTIONS] SERVICE",
Short: "Attach local standard input, output, and error streams to a service's running container.",
Short: "Attach local standard input, output, and error streams to a service's running container",
Args: cobra.MinimumNArgs(1),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
opts.service = args[0]
@@ -64,7 +64,7 @@ func attachCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}
func runAttach(ctx context.Context, dockerCli command.Cli, backend api.Service, opts attachOpts) error {
projectName, err := opts.toProjectName(dockerCli)
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -111,13 +111,13 @@ func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVar(&opts.push, "push", false, "Push service images.")
flags.BoolVar(&opts.push, "push", false, "Push service images")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Don't print anything to STDOUT")
flags.BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image.")
flags.StringArrayVar(&opts.args, "build-arg", []string{}, "Set build-time variables for services.")
flags.BoolVar(&opts.pull, "pull", false, "Always attempt to pull a newer version of the image")
flags.StringArrayVar(&opts.args, "build-arg", []string{}, "Set build-time variables for services")
flags.StringVar(&opts.ssh, "ssh", "", "Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent)")
flags.StringVar(&opts.builder, "builder", "", "Set builder to use.")
flags.BoolVar(&opts.deps, "with-dependencies", false, "Also build dependencies (transitively).")
flags.StringVar(&opts.builder, "builder", "", "Set builder to use")
flags.BoolVar(&opts.deps, "with-dependencies", false, "Also build dependencies (transitively)")
flags.Bool("parallel", true, "Build images in parallel. DEPRECATED")
flags.MarkHidden("parallel") //nolint:errcheck
@@ -136,7 +136,7 @@ func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runBuild(ctx context.Context, dockerCli command.Cli, backend api.Service, opts buildOptions, services []string) error {
project, err := opts.ToProject(dockerCli, services, cli.WithResolvedPaths(true), cli.WithoutEnvironmentResolution)
project, _, err := opts.ToProject(ctx, dockerCli, services, cli.WithResolvedPaths(true), cli.WithoutEnvironmentResolution)
if err != nil {
return err
}

View File

@@ -37,17 +37,18 @@ func noCompletion() validArgsFn {
func completeServiceNames(dockerCli command.Cli, p *ProjectOptions) validArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
p.Offline = true
project, err := p.ToProject(dockerCli, nil)
project, _, err := p.ToProject(cmd.Context(), dockerCli, nil)
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}
var values []string
serviceNames := append(project.ServiceNames(), project.DisabledServiceNames()...)
for _, s := range serviceNames {
if toComplete == "" || strings.HasPrefix(s, toComplete) {
serviceNames = append(serviceNames, s)
values = append(values, s)
}
}
return serviceNames, cobra.ShellCompDirectiveNoFileComp
return values, cobra.ShellCompDirectiveNoFileComp
}
}
@@ -72,7 +73,7 @@ func completeProjectNames(backend api.Service) func(cmd *cobra.Command, args []s
func completeProfileNames(dockerCli command.Cli, p *ProjectOptions) validArgsFn {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
p.Offline = true
project, err := p.ToProject(dockerCli, nil)
project, _, err := p.ToProject(cmd.Context(), dockerCli, nil)
if err != nil {
return nil, cobra.ShellCompDirectiveNoFileComp
}

View File

@@ -28,25 +28,26 @@ import (
"syscall"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/dotenv"
"github.com/compose-spec/compose-go/v2/loader"
"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/manager"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/internal/desktop"
"github.com/docker/compose/v2/internal/experimental"
"github.com/docker/compose/v2/internal/tracing"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/remote"
"github.com/docker/compose/v2/pkg/utils"
buildkit "github.com/moby/buildkit/util/progress/progressui"
"github.com/morikuni/aec"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/utils"
)
const (
@@ -62,8 +63,18 @@ const (
ComposeIgnoreOrphans = "COMPOSE_IGNORE_ORPHANS"
// ComposeEnvFiles defines the env files to use if --env-file isn't used
ComposeEnvFiles = "COMPOSE_ENV_FILES"
// ComposeMenu defines if the navigation menu should be rendered. Can be also set via --menu
ComposeMenu = "COMPOSE_MENU"
)
type Backend interface {
api.Service
SetDesktopClient(cli *desktop.Client)
SetExperiments(experiments *experimental.State)
}
// Command defines a compose CLI command as a func with args
type Command func(context.Context, []string) error
@@ -119,6 +130,7 @@ type ProjectOptions struct {
Compatibility bool
Progress string
Offline bool
All bool
}
// ProjectFunc does stuff within a types.Project
@@ -140,14 +152,15 @@ func (o *ProjectOptions) WithServices(dockerCli command.Cli, fn ProjectServicesF
options := []cli.ProjectOptionsFn{
cli.WithResolvedPaths(true),
cli.WithDiscardEnvFile,
cli.WithContext(ctx),
}
project, err := o.ToProject(dockerCli, args, options...)
project, metrics, err := o.ToProject(ctx, dockerCli, args, options...)
if err != nil {
return err
}
ctx = context.WithValue(ctx, tracing.MetricsKey{}, metrics)
return fn(ctx, project, args)
})
}
@@ -156,19 +169,27 @@ func (o *ProjectOptions) addProjectFlags(f *pflag.FlagSet) {
f.StringArrayVar(&o.Profiles, "profile", []string{}, "Specify a profile to enable")
f.StringVarP(&o.ProjectName, "project-name", "p", "", "Project name")
f.StringArrayVarP(&o.ConfigPaths, "file", "f", []string{}, "Compose configuration files")
f.StringArrayVar(&o.EnvFiles, "env-file", nil, "Specify an alternate environment file.")
f.StringArrayVar(&o.EnvFiles, "env-file", defaultStringArrayVar(ComposeEnvFiles), "Specify an alternate environment file")
f.StringVar(&o.ProjectDir, "project-directory", "", "Specify an alternate working directory\n(default: the path of the, first specified, Compose file)")
f.StringVar(&o.WorkDir, "workdir", "", "DEPRECATED! USE --project-directory INSTEAD.\nSpecify an alternate working directory\n(default: the path of the, first specified, Compose file)")
f.BoolVar(&o.Compatibility, "compatibility", false, "Run compose in backward compatibility mode")
f.StringVar(&o.Progress, "progress", string(buildkit.AutoMode), fmt.Sprintf(`Set type of progress output (%s)`, strings.Join(printerModes, ", ")))
f.BoolVar(&o.All, "all-resources", false, "Include all resources, even those not used by services")
_ = f.MarkHidden("workdir")
}
func (o *ProjectOptions) projectOrName(dockerCli command.Cli, services ...string) (*types.Project, string, error) {
// get default value for a command line flag that is set by a coma-separated value in environment variable
func defaultStringArrayVar(env string) []string {
return strings.FieldsFunc(os.Getenv(env), func(c rune) bool {
return c == ','
})
}
func (o *ProjectOptions) projectOrName(ctx context.Context, dockerCli command.Cli, services ...string) (*types.Project, string, error) {
name := o.ProjectName
var project *types.Project
if len(o.ConfigPaths) > 0 || o.ProjectName == "" {
p, err := o.ToProject(dockerCli, services, cli.WithDiscardEnvFile)
p, _, err := o.ToProject(ctx, dockerCli, services, cli.WithDiscardEnvFile)
if err != nil {
envProjectName := os.Getenv(ComposeProjectName)
if envProjectName != "" {
@@ -182,7 +203,7 @@ func (o *ProjectOptions) projectOrName(dockerCli command.Cli, services ...string
return project, name, nil
}
func (o *ProjectOptions) toProjectName(dockerCli command.Cli) (string, error) {
func (o *ProjectOptions) toProjectName(ctx context.Context, dockerCli command.Cli) (string, error) {
if o.ProjectName != "" {
return o.ProjectName, nil
}
@@ -192,39 +213,82 @@ func (o *ProjectOptions) toProjectName(dockerCli command.Cli) (string, error) {
return envProjectName, nil
}
project, err := o.ToProject(dockerCli, nil)
project, _, err := o.ToProject(ctx, dockerCli, nil)
if err != nil {
return "", err
}
return project.Name, nil
}
func (o *ProjectOptions) ToProject(dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
if !o.Offline {
po = o.configureRemoteLoaders(dockerCli, po)
func (o *ProjectOptions) ToModel(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (map[string]any, error) {
remotes := o.remoteLoaders(dockerCli)
for _, r := range remotes {
po = append(po, cli.WithResourceLoader(r))
}
options, err := o.toProjectOptions(po...)
if err != nil {
return nil, compose.WrapComposeError(err)
return nil, err
}
if o.Compatibility || utils.StringToBool(options.Environment[ComposeCompatibility]) {
api.Separator = "_"
}
project, err := cli.ProjectFromOptions(options)
return options.LoadModel(ctx)
}
func (o *ProjectOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, tracing.Metrics, error) { //nolint:gocyclo
var metrics tracing.Metrics
remotes := o.remoteLoaders(dockerCli)
for _, r := range remotes {
po = append(po, cli.WithResourceLoader(r))
}
options, err := o.toProjectOptions(po...)
if err != nil {
return nil, compose.WrapComposeError(err)
return nil, metrics, compose.WrapComposeError(err)
}
options.WithListeners(func(event string, metadata map[string]any) {
switch event {
case "extends":
metrics.CountExtends++
case "include":
paths := metadata["path"].(types.StringList)
for _, path := range paths {
var isRemote bool
for _, r := range remotes {
if r.Accept(path) {
isRemote = true
break
}
}
if isRemote {
metrics.CountIncludesRemote++
} else {
metrics.CountIncludesLocal++
}
}
}
})
if o.Compatibility || utils.StringToBool(options.Environment[ComposeCompatibility]) {
api.Separator = "_"
}
project, err := options.LoadProject(ctx)
if err != nil {
return nil, metrics, compose.WrapComposeError(err)
}
if project.Name == "" {
return nil, errors.New("project name can't be empty. Use `--project-name` to set a valid name")
return nil, metrics, errors.New("project name can't be empty. Use `--project-name` to set a valid name")
}
project, err = project.WithServicesEnabled(services...)
if err != nil {
return nil, err
return nil, metrics, err
}
for name, s := range project.Services {
@@ -242,29 +306,41 @@ func (o *ProjectOptions) ToProject(dockerCli command.Cli, services []string, po
project.Services[name] = s
}
project = project.WithoutUnnecessaryResources()
if !o.All {
project = project.WithoutUnnecessaryResources()
}
project, err = project.WithSelectedServices(services)
return project, err
return project, metrics, err
}
func (o *ProjectOptions) configureRemoteLoaders(dockerCli command.Cli, po []cli.ProjectOptionsFn) []cli.ProjectOptionsFn {
func (o *ProjectOptions) remoteLoaders(dockerCli command.Cli) []loader.ResourceLoader {
if o.Offline {
return nil
}
git := remote.NewGitRemoteLoader(o.Offline)
oci := remote.NewOCIRemoteLoader(dockerCli, o.Offline)
po = append(po, cli.WithResourceLoader(git), cli.WithResourceLoader(oci))
return po
return []loader.ResourceLoader{git, oci}
}
func (o *ProjectOptions) toProjectOptions(po ...cli.ProjectOptionsFn) (*cli.ProjectOptions, error) {
return cli.NewProjectOptions(o.ConfigPaths,
append(po,
cli.WithWorkingDirectory(o.ProjectDir),
// First apply os.Environment, always win
cli.WithOsEnv,
// Load PWD/.env if present and no explicit --env-file has been set
cli.WithEnvFiles(o.EnvFiles...),
// read dot env file to populate project environment
cli.WithDotEnv,
// get compose file path set by COMPOSE_FILE
cli.WithConfigFileEnv,
// if none was selected, get default compose.yaml file from current dir or parent folder
cli.WithDefaultConfigPath,
// .. and then, a project directory != PWD maybe has been set so let's load .env file
cli.WithEnvFiles(o.EnvFiles...),
cli.WithDotEnv,
cli.WithConfigFileEnv,
cli.WithDefaultConfigPath,
// eventually COMPOSE_PROFILES should have been set
cli.WithDefaultProfiles(o.Profiles...),
cli.WithName(o.ProjectName))...)
}
@@ -278,7 +354,7 @@ func RunningAsStandalone() bool {
}
// RootCommand returns the compose command with its child commands
func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //nolint:gocyclo
func RootCommand(dockerCli command.Cli, backend Backend) *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
@@ -289,6 +365,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
"commandConn.CloseRead:",
))
experiments := experimental.NewState()
opts := ProjectOptions{}
var (
ansi string
@@ -300,7 +377,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
)
c := &cobra.Command{
Short: "Docker Compose",
Long: "Define and run multi-container applications with Docker.",
Long: "Define and run multi-container applications with Docker",
Use: PluginName,
TraverseChildren: true,
// By default (no Run/RunE in parent c) for typos in subcommands, cobra displays the help of parent c but exit(0) !
@@ -318,11 +395,9 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
}
},
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
err := setEnvWithDotEnv(&opts)
if err != nil {
return err
}
ctx := cmd.Context()
parent := cmd.Root()
if parent != nil {
parentPrerun := parent.PersistentPreRunE
if parentPrerun != nil {
@@ -332,6 +407,10 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
}
}
}
if verbose {
logrus.SetLevel(logrus.TraceLevel)
}
if noAnsi {
if ansi != "auto" {
return errors.New(`cannot specify DEPRECATED "--no-ansi" and "--ansi". Please use only "--ansi"`)
@@ -339,14 +418,9 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
ansi = "never"
fmt.Fprint(os.Stderr, "option '--no-ansi' is DEPRECATED ! Please use '--ansi' instead.\n")
}
if verbose {
logrus.SetLevel(logrus.TraceLevel)
}
if v, ok := os.LookupEnv("COMPOSE_ANSI"); ok && !cmd.Flags().Changed("ansi") {
ansi = v
}
formatter.SetANSIMode(dockerCli, ansi)
if noColor, ok := os.LookupEnv("NO_COLOR"); ok && noColor != "" {
@@ -364,6 +438,9 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
switch opts.Progress {
case ui.ModeAuto:
ui.Mode = ui.ModeAuto
if ansi == "never" {
ui.Mode = ui.ModePlain
}
case ui.ModeTTY:
if ansi == "never" {
return fmt.Errorf("can't use --progress tty while ANSI support is disabled")
@@ -380,6 +457,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
return fmt.Errorf("unsupported --progress value %q", opts.Progress)
}
// (4) options validation / normalization
if opts.WorkDir != "" {
if opts.ProjectDir != "" {
return errors.New(`cannot specify DEPRECATED "--workdir" and "--project-directory". Please use only "--project-directory" instead`)
@@ -389,7 +467,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
}
for i, file := range opts.EnvFiles {
if !filepath.IsAbs(file) {
file, err = filepath.Abs(file)
file, err := filepath.Abs(file)
if err != nil {
return err
}
@@ -416,19 +494,44 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
parallel = i
}
if parallel > 0 {
logrus.Debugf("Limiting max concurrency to %d jobs", parallel)
backend.MaxConcurrency(parallel)
}
ctx, err := backend.DryRunMode(cmd.Context(), dryRun)
// dry run detection
ctx, err := backend.DryRunMode(ctx, dryRun)
if err != nil {
return err
}
cmd.SetContext(ctx)
// (6) Desktop integration
var desktopCli *desktop.Client
if !dryRun {
if desktopCli, err = desktop.NewFromDockerClient(ctx, dockerCli); desktopCli != nil {
logrus.Debugf("Enabled Docker Desktop integration (experimental) @ %s", desktopCli.Endpoint())
backend.SetDesktopClient(desktopCli)
} else if err != nil {
// not fatal, Compose will still work but behave as though
// it's not running as part of Docker Desktop
logrus.Debugf("failed to enable Docker Desktop integration: %v", err)
} else {
logrus.Trace("Docker Desktop integration not enabled")
}
}
// (7) experimental features
if err := experiments.Load(ctx, desktopCli); err != nil {
logrus.Debugf("Failed to query feature flags from Desktop: %v", err)
}
backend.SetExperiments(experiments)
return nil
},
}
c.AddCommand(
upCommand(&opts, dockerCli, backend),
upCommand(&opts, dockerCli, backend, experiments),
downCommand(&opts, dockerCli, backend),
startCommand(&opts, dockerCli, backend),
restartCommand(&opts, dockerCli, backend),
@@ -436,7 +539,7 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
psCommand(&opts, dockerCli, backend),
listCommand(dockerCli, backend),
logsCommand(&opts, dockerCli, backend),
configCommand(&opts, dockerCli, backend),
configCommand(&opts, dockerCli),
killCommand(&opts, dockerCli, backend),
runCommand(&opts, dockerCli, backend),
removeCommand(&opts, dockerCli, backend),
@@ -496,34 +599,21 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command { //
return c
}
func setEnvWithDotEnv(prjOpts *ProjectOptions) error {
if len(prjOpts.EnvFiles) == 0 {
if envFiles := os.Getenv(ComposeEnvFiles); envFiles != "" {
prjOpts.EnvFiles = strings.Split(envFiles, ",")
}
}
options, err := prjOpts.toProjectOptions()
if err != nil {
return compose.WrapComposeError(err)
}
envFromFile, err := dotenv.GetEnvFromFile(composegoutils.GetAsEqualsMap(os.Environ()), options.EnvFiles)
if err != nil {
return err
}
for k, v := range envFromFile {
if _, ok := os.LookupEnv(k); !ok { // Precedence to OS Env
if err := os.Setenv(k, v); err != nil {
return err
}
}
}
return nil
}
var printerModes = []string{
ui.ModeAuto,
ui.ModeTTY,
ui.ModePlain,
ui.ModeQuiet,
}
func SetUnchangedOption(name string, experimentalFlag bool) bool {
var value bool
// If the var is defined we use that value first
if envVar, ok := os.LookupEnv(name); ok {
value = utils.StringToBool(envVar)
} else {
// if not, we try to get it from experimental feature flag
value = experimentalFlag
}
return value
}

View File

@@ -19,15 +19,20 @@ package compose
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"os"
"sort"
"strings"
"github.com/compose-spec/compose-go/v2/cli"
"github.com/compose-spec/compose-go/v2/template"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/compose"
@@ -48,21 +53,33 @@ type configOptions struct {
images bool
hash string
noConsistency bool
variables bool
environment bool
}
func (o *configOptions) ToProject(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (*types.Project, error) {
po = append(po,
po = append(po, o.ToProjectOptions()...)
project, _, err := o.ProjectOptions.ToProject(ctx, dockerCli, services, po...)
return project, err
}
func (o *configOptions) ToModel(ctx context.Context, dockerCli command.Cli, services []string, po ...cli.ProjectOptionsFn) (map[string]any, error) {
po = append(po, o.ToProjectOptions()...)
return o.ProjectOptions.ToModel(ctx, dockerCli, services, po...)
}
func (o *configOptions) ToProjectOptions() []cli.ProjectOptionsFn {
return []cli.ProjectOptionsFn{
cli.WithInterpolation(!o.noInterpolate),
cli.WithResolvedPaths(!o.noResolvePath),
cli.WithNormalization(!o.noNormalize),
cli.WithConsistency(!o.noConsistency),
cli.WithDefaultProfiles(o.Profiles...),
cli.WithDiscardEnvFile,
cli.WithContext(ctx))
return o.ProjectOptions.ToProject(dockerCli, services, po...)
}
}
func configCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
func configCommand(p *ProjectOptions, dockerCli command.Cli) *cobra.Command {
opts := configOptions{
ProjectOptions: p,
}
@@ -99,18 +116,24 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
if opts.images {
return runConfigImages(ctx, dockerCli, opts, args)
}
if opts.variables {
return runVariables(ctx, dockerCli, opts, args)
}
if opts.environment {
return runEnvironment(ctx, dockerCli, opts, args)
}
return runConfig(ctx, dockerCli, backend, opts, args)
return runConfig(ctx, dockerCli, opts, args)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.StringVar(&opts.Format, "format", "yaml", "Format the output. Values: [yaml | json]")
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests.")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything.")
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables.")
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model.")
flags.BoolVar(&opts.noResolvePath, "no-path-resolution", false, "Don't resolve file paths.")
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Only validate the configuration, don't print anything")
flags.BoolVar(&opts.noInterpolate, "no-interpolate", false, "Don't interpolate environment variables")
flags.BoolVar(&opts.noNormalize, "no-normalize", false, "Don't normalize compose model")
flags.BoolVar(&opts.noResolvePath, "no-path-resolution", false, "Don't resolve file paths")
flags.BoolVar(&opts.noConsistency, "no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
flags.BoolVar(&opts.services, "services", false, "Print the service names, one per line.")
@@ -118,25 +141,25 @@ func configCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
flags.BoolVar(&opts.profiles, "profiles", false, "Print the profile names, one per line.")
flags.BoolVar(&opts.images, "images", false, "Print the image names, one per line.")
flags.StringVar(&opts.hash, "hash", "", "Print the service config hash, one per line.")
flags.BoolVar(&opts.variables, "variables", false, "Print model variables and default values.")
flags.BoolVar(&opts.environment, "environment", false, "Print environment used for interpolation.")
flags.StringVarP(&opts.Output, "output", "o", "", "Save to file (default to stdout)")
return cmd
}
func runConfig(ctx context.Context, dockerCli command.Cli, backend api.Service, opts configOptions, services []string) error {
func runConfig(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) (err error) {
var content []byte
project, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}
content, err = backend.Config(ctx, project, api.ConfigOptions{
Format: opts.Format,
Output: opts.Output,
ResolveImageDigests: opts.resolveImageDigests,
})
if err != nil {
return err
if opts.noInterpolate {
content, err = runConfigNoInterpolate(ctx, dockerCli, opts, services)
if err != nil {
return err
}
} else {
content, err = runConfigInterpolate(ctx, dockerCli, opts, services)
if err != nil {
return err
}
}
if !opts.noInterpolate {
@@ -154,6 +177,107 @@ func runConfig(ctx context.Context, dockerCli command.Cli, backend api.Service,
return err
}
func runConfigInterpolate(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) ([]byte, error) {
project, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return nil, err
}
if opts.resolveImageDigests {
project, err = project.WithImagesResolved(compose.ImageDigestResolver(ctx, dockerCli.ConfigFile(), dockerCli.Client()))
if err != nil {
return nil, err
}
}
if !opts.noConsistency {
err := project.CheckContainerNameUnicity()
if err != nil {
return nil, err
}
}
var content []byte
switch opts.Format {
case "json":
content, err = project.MarshalJSON()
case "yaml":
content, err = project.MarshalYAML()
default:
return nil, fmt.Errorf("unsupported format %q", opts.Format)
}
if err != nil {
return nil, err
}
return content, nil
}
func runConfigNoInterpolate(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) ([]byte, error) {
// we can't use ToProject, so the model we render here is only partially resolved
model, err := opts.ToModel(ctx, dockerCli, services)
if err != nil {
return nil, err
}
if opts.resolveImageDigests {
err = resolveImageDigests(ctx, dockerCli, model)
if err != nil {
return nil, err
}
}
return formatModel(model, opts.Format)
}
func resolveImageDigests(ctx context.Context, dockerCli command.Cli, model map[string]any) (err error) {
// create a pseudo-project so we can rely on WithImagesResolved to resolve images
p := &types.Project{
Services: types.Services{},
}
services := model["services"].(map[string]any)
for name, s := range services {
service := s.(map[string]any)
if image, ok := service["image"]; ok {
p.Services[name] = types.ServiceConfig{
Image: image.(string),
}
}
}
p, err = p.WithImagesResolved(compose.ImageDigestResolver(ctx, dockerCli.ConfigFile(), dockerCli.Client()))
if err != nil {
return err
}
// Collect image resolved with digest and update model accordingly
for name, s := range services {
service := s.(map[string]any)
config := p.Services[name]
if config.Image != "" {
service["image"] = config.Image
}
services[name] = service
}
model["services"] = services
return nil
}
func formatModel(model map[string]any, format string) (content []byte, err error) {
switch format {
case "json":
content, err = json.MarshalIndent(model, "", " ")
case "yaml":
buf := bytes.NewBuffer([]byte{})
encoder := yaml.NewEncoder(buf)
encoder.SetIndent(2)
err = encoder.Encode(model)
content = buf.Bytes()
default:
return nil, fmt.Errorf("unsupported format %q", format)
}
return
}
func runServices(ctx context.Context, dockerCli command.Cli, opts configOptions) error {
project, err := opts.ToProject(ctx, dockerCli, nil, cli.WithoutEnvironmentResolution)
if err != nil {
@@ -243,12 +367,41 @@ func runConfigImages(ctx context.Context, dockerCli command.Cli, opts configOpti
if err != nil {
return err
}
for _, s := range project.Services {
fmt.Fprintln(dockerCli.Out(), api.GetImageNameOrDefault(s, project.Name))
}
return nil
}
func runVariables(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
opts.noInterpolate = true
model, err := opts.ToModel(ctx, dockerCli, services, cli.WithoutEnvironmentResolution)
if err != nil {
return err
}
variables := template.ExtractVariables(model, template.DefaultPattern)
return formatter.Print(variables, "", dockerCli.Out(), func(w io.Writer) {
for name, variable := range variables {
_, _ = fmt.Fprintf(w, "%s\t%t\t%s\t%s\n", name, variable.Required, variable.DefaultValue, variable.PresenceValue)
}
}, "NAME", "REQUIRED", "DEFAULT VALUE", "ALTERNATE VALUE")
}
func runEnvironment(ctx context.Context, dockerCli command.Cli, opts configOptions, services []string) error {
project, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}
for _, v := range project.Environment.Values() {
fmt.Println(v)
}
return nil
}
func escapeDollarSign(marshal []byte) []byte {
dollar := []byte{'$'}
escDollar := []byte{'$', '$'}

View File

@@ -65,10 +65,10 @@ func copyCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
flags := copyCmd.Flags()
flags.IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas")
flags.BoolVar(&opts.all, "all", false, "copy to all the containers of the service.")
flags.MarkHidden("all") //nolint:errcheck
flags.MarkDeprecated("all", "by default all the containers of the service will get the source file/directory to be copied.") //nolint:errcheck
flags.IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
flags.BoolVar(&opts.all, "all", false, "Copy to all the containers of the service")
flags.MarkHidden("all") //nolint:errcheck
flags.MarkDeprecated("all", "By default all the containers of the service will get the source file/directory to be copied") //nolint:errcheck
flags.BoolVarP(&opts.followLink, "follow-link", "L", false, "Always follow symbol link in SRC_PATH")
flags.BoolVarP(&opts.copyUIDGID, "archive", "a", false, "Archive mode (copy all uid/gid information)")
@@ -76,7 +76,7 @@ func copyCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runCopy(ctx context.Context, dockerCli command.Cli, backend api.Service, opts copyOptions) error {
name, err := opts.toProjectName(dockerCli)
name, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -55,7 +55,7 @@ func createCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}
cmd := &cobra.Command{
Use: "create [OPTIONS] [SERVICE...]",
Short: "Creates containers for a service.",
Short: "Creates containers for a service",
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
opts.pullChanged = cmd.Flags().Changed("pull")
if opts.Build && opts.noBuild {
@@ -72,12 +72,13 @@ func createCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers.")
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's policy.")
flags.BoolVar(&opts.Build, "build", false, "Build images before starting containers")
flags.BoolVar(&opts.noBuild, "no-build", false, "Don't build an image, even if it's policy")
flags.StringVar(&opts.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never"|"build")`)
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
flags.BoolVar(&opts.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.BoolVar(&opts.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed")
flags.BoolVar(&opts.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
flags.BoolVar(&opts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
flags.StringArrayVar(&opts.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
return cmd
}
@@ -105,7 +106,7 @@ func runCreate(ctx context.Context, _ command.Cli, backend api.Service, createOp
RecreateDependencies: createOpts.dependenciesRecreateStrategy(),
Inherit: !createOpts.noInherit,
Timeout: createOpts.GetTimeout(),
QuietPull: false,
QuietPull: createOpts.quietPull,
})
}

View File

@@ -63,9 +63,9 @@ func downCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
flags := downCmd.Flags()
removeOrphans := utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.")
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file")
flags.IntVarP(&opts.timeout, "timeout", "t", 0, "Specify a shutdown timeout in seconds")
flags.BoolVarP(&opts.volumes, "volumes", "v", false, `Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers.`)
flags.BoolVarP(&opts.volumes, "volumes", "v", false, `Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers`)
flags.StringVar(&opts.images, "rmi", "", `Remove images used by services. "local" remove only images that don't have a custom tag ("local"|"all")`)
flags.SetNormalizeFunc(func(f *pflag.FlagSet, name string) pflag.NormalizedName {
if name == "volume" {
@@ -78,7 +78,7 @@ func downCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runDown(ctx context.Context, dockerCli command.Cli, backend api.Service, opts downOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}

View File

@@ -40,7 +40,7 @@ func eventsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}
cmd := &cobra.Command{
Use: "events [OPTIONS] [SERVICE...]",
Short: "Receive real time events from containers.",
Short: "Receive real time events from containers",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runEvents(ctx, dockerCli, backend, opts, args)
}),
@@ -52,7 +52,7 @@ func eventsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}
func runEvents(ctx context.Context, dockerCli command.Cli, backend api.Service, opts eventsOpts, services []string) error {
name, err := opts.toProjectName(dockerCli)
name, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -51,7 +51,7 @@ func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
runCmd := &cobra.Command{
Use: "exec [OPTIONS] SERVICE COMMAND [ARGS...]",
Short: "Execute a command in a running container.",
Short: "Execute a command in a running container",
Args: cobra.MinimumNArgs(2),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
opts.service = args[0]
@@ -64,17 +64,17 @@ func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
runCmd.Flags().BoolVarP(&opts.detach, "detach", "d", false, "Detached mode: Run command in the background.")
runCmd.Flags().BoolVarP(&opts.detach, "detach", "d", false, "Detached mode: Run command in the background")
runCmd.Flags().StringArrayVarP(&opts.environment, "env", "e", []string{}, "Set environment variables")
runCmd.Flags().IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas")
runCmd.Flags().BoolVarP(&opts.privileged, "privileged", "", false, "Give extended privileges to the process.")
runCmd.Flags().StringVarP(&opts.user, "user", "u", "", "Run the command as this user.")
runCmd.Flags().IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
runCmd.Flags().BoolVarP(&opts.privileged, "privileged", "", false, "Give extended privileges to the process")
runCmd.Flags().StringVarP(&opts.user, "user", "u", "", "Run the command as this user")
runCmd.Flags().BoolVarP(&opts.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY.")
runCmd.Flags().StringVarP(&opts.workingDir, "workdir", "w", "", "Path to workdir directory for this command.")
runCmd.Flags().StringVarP(&opts.workingDir, "workdir", "w", "", "Path to workdir directory for this command")
runCmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
runCmd.Flags().BoolVarP(&opts.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
runCmd.Flags().MarkHidden("interactive") //nolint:errcheck
runCmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")
runCmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY")
runCmd.Flags().MarkHidden("tty") //nolint:errcheck
runCmd.Flags().SetInterspersed(false)
@@ -82,7 +82,7 @@ func execCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runExec(ctx context.Context, dockerCli command.Cli, backend api.Service, opts execOpts) error {
projectName, err := opts.toProjectName(dockerCli)
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -51,13 +51,13 @@ func imagesCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
imgCmd.Flags().StringVar(&opts.Format, "format", "table", "Format the output. Values: [table | json].")
imgCmd.Flags().StringVar(&opts.Format, "format", "table", "Format the output. Values: [table | json]")
imgCmd.Flags().BoolVarP(&opts.Quiet, "quiet", "q", false, "Only display IDs")
return imgCmd
}
func runImages(ctx context.Context, dockerCli command.Cli, backend api.Service, opts imageOptions, services []string) error {
projectName, err := opts.toProjectName(dockerCli)
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -39,7 +39,7 @@ func killCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
cmd := &cobra.Command{
Use: "kill [OPTIONS] [SERVICE...]",
Short: "Force stop service containers.",
Short: "Force stop service containers",
RunE: Adapt(func(ctx context.Context, args []string) error {
return runKill(ctx, dockerCli, backend, opts, args)
}),
@@ -48,14 +48,14 @@ func killCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
flags := cmd.Flags()
removeOrphans := utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file.")
flags.StringVarP(&opts.signal, "signal", "s", "SIGKILL", "SIGNAL to send to the container.")
flags.BoolVar(&opts.removeOrphans, "remove-orphans", removeOrphans, "Remove containers for services not defined in the Compose file")
flags.StringVarP(&opts.signal, "signal", "s", "SIGKILL", "SIGNAL to send to the container")
return cmd
}
func runKill(ctx context.Context, dockerCli command.Cli, backend api.Service, opts killOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}

View File

@@ -49,9 +49,9 @@ func listCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
Args: cobra.NoArgs,
ValidArgsFunction: noCompletion(),
}
lsCmd.Flags().StringVar(&lsOpts.Format, "format", "table", "Format the output. Values: [table | json].")
lsCmd.Flags().BoolVarP(&lsOpts.Quiet, "quiet", "q", false, "Only display IDs.")
lsCmd.Flags().Var(&lsOpts.Filter, "filter", "Filter output based on conditions provided.")
lsCmd.Flags().StringVar(&lsOpts.Format, "format", "table", "Format the output. Values: [table | json]")
lsCmd.Flags().BoolVarP(&lsOpts.Quiet, "quiet", "q", false, "Only display IDs")
lsCmd.Flags().Var(&lsOpts.Filter, "filter", "Filter output based on conditions provided")
lsCmd.Flags().BoolVarP(&lsOpts.All, "all", "a", false, "Show all stopped Compose projects")
return lsCmd

View File

@@ -59,22 +59,32 @@ func logsCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := logsCmd.Flags()
flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output.")
flags.BoolVarP(&opts.follow, "follow", "f", false, "Follow log output")
flags.IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas")
flags.StringVar(&opts.since, "since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
flags.StringVar(&opts.until, "until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output.")
flags.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps.")
flags.StringVarP(&opts.tail, "tail", "n", "all", "Number of lines to show from the end of the logs for each container.")
flags.BoolVar(&opts.noColor, "no-color", false, "Produce monochrome output")
flags.BoolVar(&opts.noPrefix, "no-log-prefix", false, "Don't print prefix in logs")
flags.BoolVarP(&opts.timestamps, "timestamps", "t", false, "Show timestamps")
flags.StringVarP(&opts.tail, "tail", "n", "all", "Number of lines to show from the end of the logs for each container")
return logsCmd
}
func runLogs(ctx context.Context, dockerCli command.Cli, backend api.Service, opts logsOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
// exclude services configured to ignore output (attach: false), until explicitly selected
if project != nil && len(services) == 0 {
for n, service := range project.Services {
if service.Attach == nil || *service.Attach {
services = append(services, n)
}
}
}
consumer := formatter.NewLogConsumer(ctx, dockerCli.Out(), dockerCli.Err(), !opts.noColor, !opts.noPrefix, false)
return backend.Logs(ctx, name, consumer, api.LogOptions{
Project: project,

View File

@@ -45,7 +45,7 @@ func pauseCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runPause(ctx context.Context, dockerCli command.Cli, backend api.Service, opts pauseOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
@@ -76,7 +76,7 @@ func unpauseCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Servic
}
func runUnPause(ctx context.Context, dockerCli command.Cli, backend api.Service, opts unpauseOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}

View File

@@ -41,7 +41,7 @@ func portCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
cmd := &cobra.Command{
Use: "port [OPTIONS] SERVICE PRIVATE_PORT",
Short: "Print the public port for a port binding.",
Short: "Print the public port for a port binding",
Args: cobra.MinimumNArgs(2),
PreRunE: Adapt(func(ctx context.Context, args []string) error {
port, err := strconv.ParseUint(args[1], 10, 16)
@@ -58,12 +58,12 @@ func portCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().StringVar(&opts.protocol, "protocol", "tcp", "tcp or udp")
cmd.Flags().IntVar(&opts.index, "index", 0, "index of the container if service has multiple replicas")
cmd.Flags().IntVar(&opts.index, "index", 0, "Index of the container if service has multiple replicas")
return cmd
}
func runPort(ctx context.Context, dockerCli command.Cli, backend api.Service, opts portOptions, service string) error {
projectName, err := opts.toProjectName(dockerCli)
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -81,7 +81,7 @@ func psCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
}
flags := psCmd.Flags()
flags.StringVar(&opts.Format, "format", "table", cliflags.FormatHelp)
flags.StringVar(&opts.Filter, "filter", "", "Filter services by a property (supported filters: status).")
flags.StringVar(&opts.Filter, "filter", "", "Filter services by a property (supported filters: status)")
flags.StringArrayVar(&opts.Status, "status", []string{}, "Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]")
flags.BoolVarP(&opts.Quiet, "quiet", "q", false, "Only display IDs")
flags.BoolVar(&opts.Services, "services", false, "Display services")
@@ -92,7 +92,7 @@ func psCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
}
func runPs(ctx context.Context, dockerCli command.Cli, backend api.Service, services []string, opts psOptions) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}
@@ -113,7 +113,7 @@ func runPs(ctx context.Context, dockerCli command.Cli, backend api.Service, serv
containers, err := backend.Ps(ctx, name, api.PsOptions{
Project: project,
All: opts.All,
All: opts.All || len(opts.Status) != 0,
Services: services,
})
if err != nil {

View File

@@ -44,13 +44,13 @@ func publishCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Servic
Args: cobra.ExactArgs(1),
}
flags := cmd.Flags()
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests.")
flags.BoolVar(&opts.resolveImageDigests, "resolve-image-digests", false, "Pin image tags to digests")
flags.StringVar(&opts.ociVersion, "oci-version", "", "OCI Image/Artifact specification version (automatically determined by default)")
return cmd
}
func runPublish(ctx context.Context, dockerCli command.Cli, backend api.Service, opts publishOptions, repository string) error {
project, err := opts.ToProject(dockerCli, nil)
project, _, err := opts.ToProject(ctx, dockerCli, nil)
if err != nil {
return err
}

View File

@@ -60,15 +60,15 @@ func pullCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := cmd.Flags()
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information.")
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies.")
cmd.Flags().BoolVar(&opts.parallel, "parallel", true, "DEPRECATED pull multiple images in parallel.")
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Pull without printing progress information")
cmd.Flags().BoolVar(&opts.includeDeps, "include-deps", false, "Also pull services declared as dependencies")
cmd.Flags().BoolVar(&opts.parallel, "parallel", true, "DEPRECATED pull multiple images in parallel")
flags.MarkHidden("parallel") //nolint:errcheck
cmd.Flags().BoolVar(&opts.parallel, "no-parallel", true, "DEPRECATED disable parallel pulling.")
cmd.Flags().BoolVar(&opts.parallel, "no-parallel", true, "DEPRECATED disable parallel pulling")
flags.MarkHidden("no-parallel") //nolint:errcheck
cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures.")
cmd.Flags().BoolVar(&opts.noBuildable, "ignore-buildable", false, "Ignore images that can be built.")
cmd.Flags().StringVar(&opts.policy, "policy", "", `Apply pull policy ("missing"|"always").`)
cmd.Flags().BoolVar(&opts.ignorePullFailures, "ignore-pull-failures", false, "Pull what it can and ignores images with pull failures")
cmd.Flags().BoolVar(&opts.noBuildable, "ignore-buildable", false, "Ignore images that can be built")
cmd.Flags().StringVar(&opts.policy, "policy", "", `Apply pull policy ("missing"|"always")`)
return cmd
}
@@ -94,7 +94,7 @@ func (opts pullOptions) apply(project *types.Project, services []string) (*types
}
func runPull(ctx context.Context, dockerCli command.Cli, backend api.Service, opts pullOptions, services []string) error {
project, err := opts.ToProject(dockerCli, services)
project, _, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}

View File

@@ -54,7 +54,7 @@ func pushCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runPush(ctx context.Context, dockerCli command.Cli, backend api.Service, opts pushOptions, services []string) error {
project, err := opts.ToProject(dockerCli, services)
project, _, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}

View File

@@ -60,7 +60,7 @@ Any data which is not in a volume will be lost.`,
}
func runRemove(ctx context.Context, dockerCli command.Cli, backend api.Service, opts removeOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}

View File

@@ -50,13 +50,13 @@ func restartCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Servic
}
flags := restartCmd.Flags()
flags.IntVarP(&opts.timeout, "timeout", "t", 0, "Specify a shutdown timeout in seconds")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't restart dependent services.")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't restart dependent services")
return restartCmd
}
func runRestart(ctx context.Context, dockerCli command.Cli, backend api.Service, opts restartOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli)
project, name, err := opts.projectOrName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -129,7 +129,7 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
}
cmd := &cobra.Command{
Use: "run [OPTIONS] SERVICE [COMMAND] [ARGS...]",
Short: "Run a one-off command on a service.",
Short: "Run a one-off command on a service",
Args: cobra.MinimumNArgs(1),
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
options.Service = args[0]
@@ -156,7 +156,7 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
return nil
}),
RunE: Adapt(func(ctx context.Context, args []string) error {
project, err := p.ToProject(dockerCli, []string{options.Service}, cgo.WithResolvedPaths(true), cgo.WithDiscardEnvFile)
project, _, err := p.ToProject(ctx, dockerCli, []string{options.Service}, cgo.WithResolvedPaths(true), cgo.WithDiscardEnvFile)
if err != nil {
return err
}
@@ -175,24 +175,24 @@ func runCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
flags.StringArrayVarP(&options.environment, "env", "e", []string{}, "Set environment variables")
flags.StringArrayVarP(&options.labels, "label", "l", []string{}, "Add or override a label")
flags.BoolVar(&options.Remove, "rm", false, "Automatically remove the container when it exits")
flags.BoolVarP(&options.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation (default: auto-detected).")
flags.BoolVarP(&options.noTty, "no-TTY", "T", !dockerCli.Out().IsTerminal(), "Disable pseudo-TTY allocation (default: auto-detected)")
flags.StringVar(&options.name, "name", "", "Assign a name to the container")
flags.StringVarP(&options.user, "user", "u", "", "Run as specified username or uid")
flags.StringVarP(&options.workdir, "workdir", "w", "", "Working directory inside the container")
flags.StringVar(&options.entrypoint, "entrypoint", "", "Override the entrypoint of the image")
flags.Var(&options.capAdd, "cap-add", "Add Linux capabilities")
flags.Var(&options.capDrop, "cap-drop", "Drop Linux capabilities")
flags.BoolVar(&options.noDeps, "no-deps", false, "Don't start linked services.")
flags.StringArrayVarP(&options.volumes, "volume", "v", []string{}, "Bind mount a volume.")
flags.StringArrayVarP(&options.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host.")
flags.BoolVar(&options.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to.")
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host.")
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information.")
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container.")
flags.BoolVar(&createOpts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
flags.BoolVar(&options.noDeps, "no-deps", false, "Don't start linked services")
flags.StringArrayVarP(&options.volumes, "volume", "v", []string{}, "Bind mount a volume")
flags.StringArrayVarP(&options.publish, "publish", "p", []string{}, "Publish a container's port(s) to the host")
flags.BoolVar(&options.useAliases, "use-aliases", false, "Use the service's network useAliases in the network(s) the container connects to")
flags.BoolVarP(&options.servicePorts, "service-ports", "P", false, "Run command with all service's ports enabled and mapped to the host")
flags.BoolVar(&options.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.BoolVar(&createOpts.Build, "build", false, "Build image before starting container")
flags.BoolVar(&createOpts.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
cmd.Flags().BoolVarP(&options.interactive, "interactive", "i", true, "Keep STDIN open even if not attached.")
cmd.Flags().BoolVarP(&options.tty, "tty", "t", true, "Allocate a pseudo-TTY.")
cmd.Flags().BoolVarP(&options.interactive, "interactive", "i", true, "Keep STDIN open even if not attached")
cmd.Flags().BoolVarP(&options.tty, "tty", "t", true, "Allocate a pseudo-TTY")
cmd.Flags().MarkHidden("tty") //nolint:errcheck
flags.SetNormalizeFunc(normalizeRunFlags)
@@ -231,7 +231,7 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
}
buildForDeps = &bo
}
return startDependencies(ctx, backend, *project, buildForDeps, options.Service, options.ignoreOrphans)
return startDependencies(ctx, backend, *project, buildForDeps, options)
}, dockerCli.Err())
if err != nil {
return err
@@ -298,11 +298,11 @@ func runRun(ctx context.Context, backend api.Service, project *types.Project, op
return err
}
func startDependencies(ctx context.Context, backend api.Service, project types.Project, buildOpts *api.BuildOptions, requestedServiceName string, ignoreOrphans bool) error {
func startDependencies(ctx context.Context, backend api.Service, project types.Project, buildOpts *api.BuildOptions, options runOptions) error {
dependencies := types.Services{}
var requestedService types.ServiceConfig
for name, service := range project.Services {
if name != requestedServiceName {
if name != options.Service {
dependencies[name] = service
} else {
requestedService = service
@@ -310,10 +310,11 @@ func startDependencies(ctx context.Context, backend api.Service, project types.P
}
project.Services = dependencies
project.DisabledServices[requestedServiceName] = requestedService
project.DisabledServices[options.Service] = requestedService
err := backend.Create(ctx, &project, api.CreateOptions{
Build: buildOpts,
IgnoreOrphans: ignoreOrphans,
IgnoreOrphans: options.ignoreOrphans,
QuietPull: options.quietPull,
})
if err != nil {
return err

View File

@@ -54,14 +54,14 @@ func scaleCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := scaleCmd.Flags()
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't start linked services.")
flags.BoolVar(&opts.noDeps, "no-deps", false, "Don't start linked services")
return scaleCmd
}
func runScale(ctx context.Context, dockerCli command.Cli, backend api.Service, opts scaleOptions, serviceReplicaTuples map[string]int) error {
services := maps.Keys(serviceReplicaTuples)
project, err := opts.ToProject(dockerCli, services)
project, _, err := opts.ToProject(ctx, dockerCli, services)
if err != nil {
return err
}

View File

@@ -44,7 +44,7 @@ func startCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runStart(ctx context.Context, dockerCli command.Cli, backend api.Service, opts startOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}

View File

@@ -63,7 +63,7 @@ Refer to https://docs.docker.com/go/formatting/ for more information about forma
}
func runStats(ctx context.Context, dockerCli command.Cli, opts statsOptions, service []string) error {
name, err := opts.ProjectOptions.toProjectName(dockerCli)
name, err := opts.ProjectOptions.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -54,7 +54,7 @@ func stopCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runStop(ctx context.Context, dockerCli command.Cli, backend api.Service, opts stopOptions, services []string) error {
project, name, err := opts.projectOrName(dockerCli, services...)
project, name, err := opts.projectOrName(ctx, dockerCli, services...)
if err != nil {
return err
}

View File

@@ -50,7 +50,7 @@ func topCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
}
func runTop(ctx context.Context, dockerCli command.Cli, backend api.Service, opts topOptions, services []string) error {
projectName, err := opts.toProjectName(dockerCli)
projectName, err := opts.toProjectName(ctx, dockerCli)
if err != nil {
return err
}

View File

@@ -20,17 +20,19 @@ import (
"context"
"errors"
"fmt"
"os"
"strings"
"time"
xprogress "github.com/moby/buildkit/util/progress/progressui"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/compose/v2/internal/experimental"
xprogress "github.com/moby/buildkit/util/progress/progressui"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/pkg/api"
ui "github.com/docker/compose/v2/pkg/progress"
"github.com/docker/compose/v2/pkg/utils"
)
@@ -41,19 +43,23 @@ type composeOptions struct {
type upOptions struct {
*composeOptions
Detach bool
noStart bool
noDeps bool
cascadeStop bool
exitCodeFrom string
noColor bool
noPrefix bool
attachDependencies bool
attach []string
noAttach []string
timestamp bool
wait bool
waitTimeout int
Detach bool
noStart bool
noDeps bool
cascadeStop bool
cascadeFail bool
exitCodeFrom string
noColor bool
noPrefix bool
attachDependencies bool
attach []string
noAttach []string
timestamp bool
wait bool
waitTimeout int
watch bool
navigationMenu bool
navigationMenuChanged bool
}
func (opts upOptions) apply(project *types.Project, services []string) (*types.Project, error) {
@@ -75,7 +81,28 @@ func (opts upOptions) apply(project *types.Project, services []string) (*types.P
return project, nil
}
func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
func (opts *upOptions) validateNavigationMenu(dockerCli command.Cli, experimentals *experimental.State) {
if !dockerCli.Out().IsTerminal() {
opts.navigationMenu = false
return
}
if !opts.navigationMenuChanged {
opts.navigationMenu = SetUnchangedOption(ComposeMenu, experimentals.NavBar())
}
}
func (opts upOptions) OnExit() api.Cascade {
switch {
case opts.cascadeStop:
return api.CascadeStop
case opts.cascadeFail:
return api.CascadeFail
default:
return api.CascadeIgnore
}
}
func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, experiments *experimental.State) *cobra.Command {
up := upOptions{}
create := createOptions{}
build := buildOptions{ProjectOptions: p}
@@ -85,6 +112,10 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
PreRunE: AdaptCmd(func(ctx context.Context, cmd *cobra.Command, args []string) error {
create.pullChanged = cmd.Flags().Changed("pull")
create.timeChanged = cmd.Flags().Changed("timeout")
up.navigationMenuChanged = cmd.Flags().Changed("menu")
if !cmd.Flags().Changed("remove-orphans") {
create.removeOrphans = utils.StringToBool(os.Getenv(ComposeRemoveOrphans))
}
return validateFlags(&up, &create)
}),
RunE: p.WithServices(dockerCli, func(ctx context.Context, project *types.Project, services []string) error {
@@ -95,43 +126,57 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *c
if len(up.attach) != 0 && up.attachDependencies {
return errors.New("cannot combine --attach and --attach-dependencies")
}
up.validateNavigationMenu(dockerCli, experiments)
if !p.All && len(project.Services) == 0 {
return fmt.Errorf("no service selected")
}
return runUp(ctx, dockerCli, backend, create, up, build, project, services)
}),
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
flags := upCmd.Flags()
flags.BoolVarP(&up.Detach, "detach", "d", false, "Detached mode: Run containers in the background")
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers.")
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy.")
flags.BoolVar(&create.Build, "build", false, "Build images before starting containers")
flags.BoolVar(&create.noBuild, "no-build", false, "Don't build an image, even if it's policy")
flags.StringVar(&create.Pull, "pull", "policy", `Pull image before running ("always"|"missing"|"never")`)
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file.")
flags.BoolVar(&create.removeOrphans, "remove-orphans", false, "Remove containers for services not defined in the Compose file")
flags.StringArrayVar(&create.scale, "scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output.")
flags.BoolVar(&up.noPrefix, "no-log-prefix", false, "Don't print prefix in logs.")
flags.BoolVar(&create.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
flags.BoolVar(&up.noColor, "no-color", false, "Produce monochrome output")
flags.BoolVar(&up.noPrefix, "no-log-prefix", false, "Don't print prefix in logs")
flags.BoolVar(&create.forceRecreate, "force-recreate", false, "Recreate containers even if their configuration and image haven't changed")
flags.BoolVar(&create.noRecreate, "no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
flags.BoolVar(&up.noStart, "no-start", false, "Don't start the services after creating them.")
flags.BoolVar(&up.noStart, "no-start", false, "Don't start the services after creating them")
flags.BoolVar(&up.cascadeStop, "abort-on-container-exit", false, "Stops all containers if any container was stopped. Incompatible with -d")
flags.BoolVar(&up.cascadeFail, "abort-on-container-failure", false, "Stops all containers if any container exited with failure. Incompatible with -d")
flags.StringVar(&up.exitCodeFrom, "exit-code-from", "", "Return the exit code of the selected service container. Implies --abort-on-container-exit")
flags.IntVarP(&create.timeout, "timeout", "t", 0, "Use this timeout in seconds for container shutdown when attached or when containers are already running.")
flags.BoolVar(&up.timestamp, "timestamps", false, "Show timestamps.")
flags.BoolVar(&up.noDeps, "no-deps", false, "Don't start linked services.")
flags.IntVarP(&create.timeout, "timeout", "t", 0, "Use this timeout in seconds for container shutdown when attached or when containers are already running")
flags.BoolVar(&up.timestamp, "timestamps", false, "Show timestamps")
flags.BoolVar(&up.noDeps, "no-deps", false, "Don't start linked services")
flags.BoolVar(&create.recreateDeps, "always-recreate-deps", false, "Recreate dependent containers. Incompatible with --no-recreate.")
flags.BoolVarP(&create.noInherit, "renew-anon-volumes", "V", false, "Recreate anonymous volumes instead of retrieving data from the previous containers.")
flags.BoolVar(&create.quietPull, "quiet-pull", false, "Pull without printing progress information.")
flags.BoolVarP(&create.noInherit, "renew-anon-volumes", "V", false, "Recreate anonymous volumes instead of retrieving data from the previous containers")
flags.BoolVar(&create.quietPull, "quiet-pull", false, "Pull without printing progress information")
flags.StringArrayVar(&up.attach, "attach", []string{}, "Restrict attaching to the specified services. Incompatible with --attach-dependencies.")
flags.StringArrayVar(&up.noAttach, "no-attach", []string{}, "Do not attach (stream logs) to the specified services.")
flags.BoolVar(&up.attachDependencies, "attach-dependencies", false, "Automatically attach to log output of dependent services.")
flags.StringArrayVar(&up.noAttach, "no-attach", []string{}, "Do not attach (stream logs) to the specified services")
flags.BoolVar(&up.attachDependencies, "attach-dependencies", false, "Automatically attach to log output of dependent services")
flags.BoolVar(&up.wait, "wait", false, "Wait for services to be running|healthy. Implies detached mode.")
flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration to wait for the project to be running|healthy.")
flags.IntVar(&up.waitTimeout, "wait-timeout", 0, "Maximum duration to wait for the project to be running|healthy")
flags.BoolVarP(&up.watch, "watch", "w", false, "Watch source code and rebuild/refresh containers when files are updated.")
flags.BoolVar(&up.navigationMenu, "menu", false, "Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.")
return upCmd
}
//nolint:gocyclo
func validateFlags(up *upOptions, create *createOptions) error {
if up.exitCodeFrom != "" {
if up.exitCodeFrom != "" && !up.cascadeFail {
up.cascadeStop = true
}
if up.cascadeStop && up.cascadeFail {
return fmt.Errorf("--abort-on-container-failure cannot be combined with --abort-on-container-exit")
}
if up.wait {
if up.attachDependencies || up.cascadeStop || len(up.attach) > 0 {
return fmt.Errorf("--wait cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
@@ -141,8 +186,8 @@ func validateFlags(up *upOptions, create *createOptions) error {
if create.Build && create.noBuild {
return fmt.Errorf("--build and --no-build are incompatible")
}
if up.Detach && (up.attachDependencies || up.cascadeStop || len(up.attach) > 0) {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --attach or --attach-dependencies")
if up.Detach && (up.attachDependencies || up.cascadeStop || up.cascadeFail || len(up.attach) > 0 || up.watch) {
return fmt.Errorf("--detach cannot be combined with --abort-on-container-exit, --abort-on-container-failure, --attach, --attach-dependencies or --watch")
}
if create.forceRecreate && create.noRecreate {
return fmt.Errorf("--force-recreate and --no-recreate are incompatible")
@@ -150,6 +195,9 @@ func validateFlags(up *upOptions, create *createOptions) error {
if create.recreateDeps && create.noRecreate {
return fmt.Errorf("--always-recreate-deps and --no-recreate are incompatible")
}
if create.noBuild && up.watch {
return fmt.Errorf("--no-build and --watch are incompatible")
}
return nil
}
@@ -163,10 +211,6 @@ func runUp(
project *types.Project,
services []string,
) error {
if len(project.Services) == 0 {
return fmt.Errorf("no service selected")
}
err := createOptions.Apply(project)
if err != nil {
return err
@@ -248,14 +292,16 @@ func runUp(
return backend.Up(ctx, project, api.UpOptions{
Create: create,
Start: api.StartOptions{
Project: project,
Attach: consumer,
AttachTo: attach,
ExitCodeFrom: upOptions.exitCodeFrom,
CascadeStop: upOptions.cascadeStop,
Wait: upOptions.wait,
WaitTimeout: timeout,
Services: services,
Project: project,
Attach: consumer,
AttachTo: attach,
ExitCodeFrom: upOptions.exitCodeFrom,
OnExit: upOptions.OnExit(),
Wait: upOptions.wait,
WaitTimeout: timeout,
Watch: upOptions.watch,
Services: services,
NavigationMenu: upOptions.navigationMenu && ui.Mode != "plain",
},
})
}

View File

@@ -52,7 +52,7 @@ func versionCommand(dockerCli command.Cli) *cobra.Command {
// define flags for backward compatibility with com.docker.cli
flags := cmd.Flags()
flags.StringVarP(&opts.format, "format", "f", "", "Format the output. Values: [pretty | json]. (Default: pretty)")
flags.BoolVar(&opts.short, "short", false, "Shows only Compose's version number.")
flags.BoolVar(&opts.short, "short", false, "Shows only Compose's version number")
return cmd
}

View File

@@ -65,7 +65,7 @@ func vizCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *
func runViz(ctx context.Context, dockerCli command.Cli, backend api.Service, opts *vizOptions) error {
_, _ = fmt.Fprintln(os.Stderr, "viz command is EXPERIMENTAL")
project, err := opts.ToProject(dockerCli, nil)
project, _, err := opts.ToProject(ctx, dockerCli, nil)
if err != nil {
return err
}

View File

@@ -61,7 +61,7 @@ func waitCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
}
func runWait(ctx context.Context, dockerCli command.Cli, backend api.Service, opts *waitOptions) (int64, error) {
_, name, err := opts.projectOrName(dockerCli)
_, name, err := opts.projectOrName(ctx, dockerCli)
if err != nil {
return 0, err
}

View File

@@ -21,6 +21,7 @@ import (
"fmt"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/compose/v2/cmd/formatter"
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/internal/locker"
@@ -31,8 +32,7 @@ import (
type watchOptions struct {
*ProjectOptions
quiet bool
noUp bool
noUp bool
}
func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service) *cobra.Command {
@@ -57,13 +57,13 @@ func watchCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
ValidArgsFunction: completeServiceNames(dockerCli, p),
}
cmd.Flags().BoolVar(&watchOpts.quiet, "quiet", false, "hide build output")
cmd.Flags().BoolVar(&buildOpts.quiet, "quiet", false, "hide build output")
cmd.Flags().BoolVar(&watchOpts.noUp, "no-up", false, "Do not build & start services before watching")
return cmd
}
func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, watchOpts watchOptions, buildOpts buildOptions, services []string) error {
project, err := watchOpts.ToProject(dockerCli, nil)
project, _, err := watchOpts.ToProject(ctx, dockerCli, nil)
if err != nil {
return err
}
@@ -101,20 +101,22 @@ func runWatch(ctx context.Context, dockerCli command.Cli, backend api.Service, w
Recreate: api.RecreateDiverged,
RecreateDependencies: api.RecreateNever,
Inherit: true,
QuietPull: watchOpts.quiet,
QuietPull: buildOpts.quiet,
},
Start: api.StartOptions{
Project: project,
Attach: nil,
CascadeStop: false,
Services: services,
Project: project,
Attach: nil,
Services: services,
},
}
if err := backend.Up(ctx, project, upOpts); err != nil {
return err
}
}
consumer := formatter.NewLogConsumer(ctx, dockerCli.Out(), dockerCli.Err(), false, false, false)
return backend.Watch(ctx, project, services, api.WatchOptions{
Build: build,
Build: &build,
LogTo: consumer,
})
}

96
cmd/formatter/ansi.go Normal file
View File

@@ -0,0 +1,96 @@
/*
Copyright 2024 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package formatter
import (
"fmt"
"github.com/acarl005/stripansi"
)
var disableAnsi bool
func ansi(code string) string {
return fmt.Sprintf("\033%s", code)
}
func SaveCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("7"))
}
func RestoreCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("8"))
}
func HideCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("[?25l"))
}
func ShowCursor() {
if disableAnsi {
return
}
fmt.Print(ansi("[?25h"))
}
func MoveCursor(y, x int) {
if disableAnsi {
return
}
fmt.Print(ansi(fmt.Sprintf("[%d;%dH", y, x)))
}
func MoveCursorX(pos int) {
if disableAnsi {
return
}
fmt.Print(ansi(fmt.Sprintf("[%dG", pos)))
}
func ClearLine() {
if disableAnsi {
return
}
// Does not move cursor from its current position
fmt.Print(ansi("[2K"))
}
func MoveCursorUp(lines int) {
if disableAnsi {
return
}
// Does not add new lines
fmt.Print(ansi(fmt.Sprintf("[%dA", lines)))
}
func MoveCursorDown(lines int) {
if disableAnsi {
return
}
// Does not add new lines
fmt.Print(ansi(fmt.Sprintf("[%dB", lines)))
}
func NewLine() {
// Like \n
fmt.Print("\012")
}
func lenAnsi(s string) int {
// len has into consideration ansi codes, if we want
// the len of the actual len(string) we need to strip
// all ansi codes
return len(stripansi.Strip(s))
}

View File

@@ -35,6 +35,18 @@ var names = []string{
"white",
}
const (
BOLD = "1"
FAINT = "2"
ITALIC = "3"
UNDERLINE = "4"
)
const (
RESET = "0"
CYAN = "36"
)
const (
// Never use ANSI codes
Never = "never"
@@ -52,6 +64,7 @@ func SetANSIMode(streams api.Streams, ansi string) {
nextColor = func() colorFunc {
return monochrome
}
disableAnsi = true
}
}
@@ -72,12 +85,17 @@ var monochrome = func(s string) string {
return s
}
func ansiColor(code, s string) string {
return fmt.Sprintf("%s%s%s", ansi(code), s, ansi("0"))
func ansiColor(code, s string, formatOpts ...string) string {
return fmt.Sprintf("%s%s%s", ansiColorCode(code, formatOpts...), s, ansiColorCode("0"))
}
func ansi(code string) string {
return fmt.Sprintf("\033[%sm", code)
// Everything about ansiColorCode color https://hyperskill.org/learn/step/18193
func ansiColorCode(code string, formatOpts ...string) string {
res := "\033["
for _, c := range formatOpts {
res = fmt.Sprintf("%s%s;", res, c)
}
return fmt.Sprintf("%s%sm", res, code)
}
func makeColorFunc(code string) colorFunc {

View File

@@ -25,6 +25,7 @@ import (
"sync"
"time"
"github.com/buger/goterm"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/docker/pkg/jsonmessage"
)
@@ -62,7 +63,11 @@ func (l *logConsumer) Register(name string) {
func (l *logConsumer) register(name string) *presenter {
cf := monochrome
if l.color {
cf = nextColor()
if name == api.WatchLogger {
cf = makeColorFunc("92")
} else {
cf = nextColor()
}
}
p := &presenter{
colors: cf,
@@ -102,6 +107,10 @@ func (l *logConsumer) write(w io.Writer, container, message string) {
if l.ctx.Err() != nil {
return
}
if KeyboardManager != nil {
KeyboardManager.ClearKeyboardInfo()
}
p := l.getPresenter(container)
timestamp := time.Now().Format(jsonmessage.RFC3339NanoFixed)
for _, line := range strings.Split(message, "\n") {
@@ -111,11 +120,15 @@ func (l *logConsumer) write(w io.Writer, container, message string) {
fmt.Fprintf(w, "%s%s\n", p.prefix, line)
}
}
if KeyboardManager != nil {
KeyboardManager.PrintKeyboardInfo()
}
}
func (l *logConsumer) Status(container, msg string) {
p := l.getPresenter(container)
s := p.colors(fmt.Sprintf("%s %s\n", container, msg))
s := p.colors(fmt.Sprintf("%s%s %s\n", goterm.RESET_LINE, container, msg))
l.stdout.Write([]byte(s)) //nolint:errcheck
}
@@ -138,5 +151,9 @@ type presenter struct {
}
func (p *presenter) setPrefix(width int) {
if p.name == api.WatchLogger {
p.prefix = p.colors(strings.Repeat(" ", width) + " ⦿ ")
return
}
p.prefix = p.colors(fmt.Sprintf("%-"+strconv.Itoa(width)+"s | ", p.name))
}

377
cmd/formatter/shortcut.go Normal file
View File

@@ -0,0 +1,377 @@
/*
Copyright 2024 Docker Compose CLI authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package formatter
import (
"context"
"errors"
"fmt"
"math"
"os"
"syscall"
"time"
"github.com/buger/goterm"
"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/compose/v2/internal/tracing"
"github.com/docker/compose/v2/pkg/api"
"github.com/docker/compose/v2/pkg/watch"
"github.com/eiannone/keyboard"
"github.com/hashicorp/go-multierror"
"github.com/skratchdot/open-golang/open"
)
const DISPLAY_ERROR_TIME = 10
type KeyboardError struct {
err error
timeStart time.Time
}
func (ke *KeyboardError) shouldDisplay() bool {
return ke.err != nil && int(time.Since(ke.timeStart).Seconds()) < DISPLAY_ERROR_TIME
}
func (ke *KeyboardError) printError(height int, info string) {
if ke.shouldDisplay() {
errMessage := ke.err.Error()
MoveCursor(height-1-extraLines(info)-extraLines(errMessage), 0)
ClearLine()
fmt.Print(errMessage)
}
}
func (ke *KeyboardError) addError(prefix string, err error) {
ke.timeStart = time.Now()
prefix = ansiColor(CYAN, fmt.Sprintf("%s →", prefix), BOLD)
errorString := fmt.Sprintf("%s %s", prefix, err.Error())
ke.err = errors.New(errorString)
}
func (ke *KeyboardError) error() string {
return ke.err.Error()
}
type KeyboardWatch struct {
Watcher watch.Notify
Watching bool
WatchFn func(ctx context.Context, doneCh chan bool, project *types.Project, services []string, options api.WatchOptions) error
Ctx context.Context
Cancel context.CancelFunc
}
func (kw *KeyboardWatch) isWatching() bool {
return kw.Watching
}
func (kw *KeyboardWatch) switchWatching() {
kw.Watching = !kw.Watching
}
func (kw *KeyboardWatch) newContext(ctx context.Context) context.CancelFunc {
ctx, cancel := context.WithCancel(ctx)
kw.Ctx = ctx
kw.Cancel = cancel
return cancel
}
type KEYBOARD_LOG_LEVEL int
const (
NONE KEYBOARD_LOG_LEVEL = 0
INFO KEYBOARD_LOG_LEVEL = 1
DEBUG KEYBOARD_LOG_LEVEL = 2
)
type LogKeyboard struct {
kError KeyboardError
Watch KeyboardWatch
IsDockerDesktopActive bool
IsWatchConfigured bool
IsDDComposeUIActive bool
logLevel KEYBOARD_LOG_LEVEL
signalChannel chan<- os.Signal
}
var KeyboardManager *LogKeyboard
var eg multierror.Group
func NewKeyboardManager(ctx context.Context, isDockerDesktopActive, isWatchConfigured, isDockerDesktopConfigActive bool,
sc chan<- os.Signal,
watchFn func(ctx context.Context,
doneCh chan bool,
project *types.Project,
services []string,
options api.WatchOptions,
) error,
) {
km := LogKeyboard{}
km.IsDockerDesktopActive = isDockerDesktopActive
km.IsWatchConfigured = isWatchConfigured
km.IsDDComposeUIActive = isDockerDesktopConfigActive
km.logLevel = INFO
km.Watch.Watching = false
km.Watch.WatchFn = watchFn
km.signalChannel = sc
KeyboardManager = &km
}
func (lk *LogKeyboard) ClearKeyboardInfo() {
lk.clearNavigationMenu()
}
func (lk *LogKeyboard) PrintKeyboardInfo() {
if lk.logLevel == INFO {
lk.printNavigationMenu()
}
}
// Creates space to print error and menu string
func (lk *LogKeyboard) createBuffer(lines int) {
if lk.kError.shouldDisplay() {
extraLines := extraLines(lk.kError.error()) + 1
lines += extraLines
}
// get the string
infoMessage := lk.navigationMenu()
// calculate how many lines we need to display the menu info
// might be needed a line break
extraLines := extraLines(infoMessage) + 1
lines += extraLines
if lines > 0 {
allocateSpace(lines)
MoveCursorUp(lines)
}
}
func (lk *LogKeyboard) printNavigationMenu() {
offset := 1
lk.clearNavigationMenu()
lk.createBuffer(offset)
if lk.logLevel == INFO {
height := goterm.Height()
menu := lk.navigationMenu()
MoveCursorX(0)
SaveCursor()
lk.kError.printError(height, menu)
MoveCursor(height-extraLines(menu), 0)
ClearLine()
fmt.Print(menu)
MoveCursorX(0)
RestoreCursor()
}
}
func (lk *LogKeyboard) navigationMenu() string {
var openDDInfo string
if lk.IsDockerDesktopActive {
openDDInfo = shortcutKeyColor("v") + navColor(" View in Docker Desktop")
}
var openDDUI string
if openDDInfo != "" {
openDDUI = navColor(" ")
}
if lk.IsDDComposeUIActive {
openDDUI = openDDUI + shortcutKeyColor("o") + navColor(" View Config")
}
var watchInfo string
if openDDInfo != "" || openDDUI != "" {
watchInfo = navColor(" ")
}
var isEnabled = " Enable"
if lk.Watch.Watching {
isEnabled = " Disable"
}
watchInfo = watchInfo + shortcutKeyColor("w") + navColor(isEnabled+" Watch")
return openDDInfo + openDDUI + watchInfo
}
func (lk *LogKeyboard) clearNavigationMenu() {
height := goterm.Height()
MoveCursorX(0)
SaveCursor()
// ClearLine()
for i := 0; i < height; i++ {
MoveCursorDown(1)
ClearLine()
}
RestoreCursor()
}
func (lk *LogKeyboard) openDockerDesktop(ctx context.Context, project *types.Project) {
if !lk.IsDockerDesktopActive {
return
}
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/gui", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/apps/%s", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("Could not open Docker Desktop")
lk.keyboardError("View", err)
}
return err
}),
)
}
func (lk *LogKeyboard) openDDComposeUI(ctx context.Context, project *types.Project) {
if !lk.IsDDComposeUIActive {
return
}
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/composeview", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("Could not open Docker Desktop Compose UI")
lk.keyboardError("View Config", err)
}
return err
}),
)
}
func (lk *LogKeyboard) openDDWatchDocs(ctx context.Context, project *types.Project) {
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/gui/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
link := fmt.Sprintf("docker-desktop://dashboard/docker-compose/%s/watch", project.Name)
err := open.Run(link)
if err != nil {
err = fmt.Errorf("Could not open Docker Desktop Compose UI")
lk.keyboardError("Watch Docs", err)
}
return err
}),
)
}
func (lk *LogKeyboard) keyboardError(prefix string, err error) {
lk.kError.addError(prefix, err)
lk.printNavigationMenu()
timer1 := time.NewTimer((DISPLAY_ERROR_TIME + 1) * time.Second)
go func() {
<-timer1.C
lk.printNavigationMenu()
}()
}
func (lk *LogKeyboard) StartWatch(ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions) {
if !lk.IsWatchConfigured {
if lk.IsDDComposeUIActive {
// we try to open watch docs
lk.openDDWatchDocs(ctx, project)
}
// either way we mark menu/watch as an error
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
err := fmt.Errorf("Watch is not yet configured. Learn more: %s", ansiColor(CYAN, "https://docs.docker.com/compose/file-watch/"))
lk.keyboardError("Watch", err)
return err
}))
return
}
lk.Watch.switchWatching()
if !lk.Watch.isWatching() {
lk.Watch.Cancel()
} else {
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
if options.Create.Build == nil {
err := fmt.Errorf("Cannot run watch mode with flag --no-build")
lk.keyboardError("Watch", err)
return err
}
lk.Watch.newContext(ctx)
buildOpts := *options.Create.Build
buildOpts.Quiet = true
return lk.Watch.WatchFn(lk.Watch.Ctx, doneCh, project, options.Start.Services, api.WatchOptions{
Build: &buildOpts,
LogTo: options.Start.Attach,
})
}))
}
}
func (lk *LogKeyboard) HandleKeyEvents(event keyboard.KeyEvent, ctx context.Context, doneCh chan bool, project *types.Project, options api.UpOptions) {
switch kRune := event.Rune; kRune {
case 'v':
lk.openDockerDesktop(ctx, project)
case 'w':
lk.StartWatch(ctx, doneCh, project, options)
case 'o':
lk.openDDComposeUI(ctx, project)
}
switch key := event.Key; key {
case keyboard.KeyCtrlC:
_ = keyboard.Close()
lk.clearNavigationMenu()
ShowCursor()
lk.logLevel = NONE
if lk.Watch.Watching && lk.Watch.Cancel != nil {
lk.Watch.Cancel()
_ = eg.Wait().ErrorOrNil() // Need to print this ?
}
// will notify main thread to kill and will handle gracefully
lk.signalChannel <- syscall.SIGINT
case keyboard.KeyEnter:
lk.printNavigationMenu()
}
}
func allocateSpace(lines int) {
for i := 0; i < lines; i++ {
ClearLine()
NewLine()
MoveCursorX(0)
}
}
func extraLines(s string) int {
return int(math.Floor(float64(lenAnsi(s)) / float64(goterm.Width())))
}
func shortcutKeyColor(key string) string {
foreground := "38;2"
black := "0;0;0"
background := "48;2"
white := "255;255;255"
return ansiColor(foreground+";"+black+";"+background+";"+white, key, BOLD)
}
func navColor(key string) string {
return ansiColor(FAINT, key)
}

View File

@@ -25,6 +25,7 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v2/cmd/cmdtrace"
"github.com/docker/docker/client"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/docker/compose/v2/cmd/compatibility"
@@ -35,9 +36,12 @@ import (
func pluginMain() {
plugin.Run(func(dockerCli command.Cli) *cobra.Command {
backend := compose.NewComposeService(dockerCli)
// TODO(milas): this cast is safe but we should not need to do this,
// we should expose the concrete service type so that we do not need
// to rely on the `api.Service` interface internally
backend := compose.NewComposeService(dockerCli).(commands.Backend)
cmd := commands.RootCommand(dockerCli, backend)
originalPreRun := cmd.PersistentPreRunE
originalPreRunE := cmd.PersistentPreRunE
cmd.PersistentPreRunE = func(cmd *cobra.Command, args []string) error {
// initialize the dockerCli instance
if err := plugin.PersistentPreRunE(cmd, args); err != nil {
@@ -46,12 +50,12 @@ func pluginMain() {
// compose-specific initialization
dockerCliPostInitialize(dockerCli)
// TODO(milas): add an env var to enable logging from the
// OTel components for debugging purposes
_ = cmdtrace.Setup(cmd, dockerCli, os.Args[1:])
if err := cmdtrace.Setup(cmd, dockerCli, os.Args[1:]); err != nil {
logrus.Debugf("failed to enable tracing: %v", err)
}
if originalPreRun != nil {
return originalPreRun(cmd, args)
if originalPreRunE != nil {
return originalPreRunE(cmd, args)
}
return nil
}

View File

@@ -1,52 +1,53 @@
# docker compose
<!---MARKER_GEN_START-->
Define and run multi-container applications with Docker.
Define and run multi-container applications with Docker
### Subcommands
| Name | Description |
|:--------------------------------|:-----------------------------------------------------------------------------------------|
| [`attach`](compose_attach.md) | Attach local standard input, output, and error streams to a service's running container. |
| [`build`](compose_build.md) | Build or rebuild services |
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
| [`create`](compose_create.md) | Creates containers for a service. |
| [`down`](compose_down.md) | Stop and remove containers, networks |
| [`events`](compose_events.md) | Receive real time events from containers. |
| [`exec`](compose_exec.md) | Execute a command in a running container. |
| [`images`](compose_images.md) | List images used by the created containers |
| [`kill`](compose_kill.md) | Force stop service containers. |
| [`logs`](compose_logs.md) | View output from containers |
| [`ls`](compose_ls.md) | List running compose projects |
| [`pause`](compose_pause.md) | Pause services |
| [`port`](compose_port.md) | Print the public port for a port binding. |
| [`ps`](compose_ps.md) | List containers |
| [`pull`](compose_pull.md) | Pull service images |
| [`push`](compose_push.md) | Push service images |
| [`restart`](compose_restart.md) | Restart service containers |
| [`rm`](compose_rm.md) | Removes stopped service containers |
| [`run`](compose_run.md) | Run a one-off command on a service. |
| [`scale`](compose_scale.md) | Scale services |
| [`start`](compose_start.md) | Start services |
| [`stats`](compose_stats.md) | Display a live stream of container(s) resource usage statistics |
| [`stop`](compose_stop.md) | Stop services |
| [`top`](compose_top.md) | Display the running processes |
| [`unpause`](compose_unpause.md) | Unpause services |
| [`up`](compose_up.md) | Create and start containers |
| [`version`](compose_version.md) | Show the Docker Compose version information |
| [`wait`](compose_wait.md) | Block until the first service container stops |
| [`watch`](compose_watch.md) | Watch build context for service and rebuild/refresh containers when files are updated |
| Name | Description |
|:--------------------------------|:----------------------------------------------------------------------------------------|
| [`attach`](compose_attach.md) | Attach local standard input, output, and error streams to a service's running container |
| [`build`](compose_build.md) | Build or rebuild services |
| [`config`](compose_config.md) | Parse, resolve and render compose file in canonical format |
| [`cp`](compose_cp.md) | Copy files/folders between a service container and the local filesystem |
| [`create`](compose_create.md) | Creates containers for a service |
| [`down`](compose_down.md) | Stop and remove containers, networks |
| [`events`](compose_events.md) | Receive real time events from containers |
| [`exec`](compose_exec.md) | Execute a command in a running container |
| [`images`](compose_images.md) | List images used by the created containers |
| [`kill`](compose_kill.md) | Force stop service containers |
| [`logs`](compose_logs.md) | View output from containers |
| [`ls`](compose_ls.md) | List running compose projects |
| [`pause`](compose_pause.md) | Pause services |
| [`port`](compose_port.md) | Print the public port for a port binding |
| [`ps`](compose_ps.md) | List containers |
| [`pull`](compose_pull.md) | Pull service images |
| [`push`](compose_push.md) | Push service images |
| [`restart`](compose_restart.md) | Restart service containers |
| [`rm`](compose_rm.md) | Removes stopped service containers |
| [`run`](compose_run.md) | Run a one-off command on a service |
| [`scale`](compose_scale.md) | Scale services |
| [`start`](compose_start.md) | Start services |
| [`stats`](compose_stats.md) | Display a live stream of container(s) resource usage statistics |
| [`stop`](compose_stop.md) | Stop services |
| [`top`](compose_top.md) | Display the running processes |
| [`unpause`](compose_unpause.md) | Unpause services |
| [`up`](compose_up.md) | Create and start containers |
| [`version`](compose_version.md) | Show the Docker Compose version information |
| [`wait`](compose_wait.md) | Block until the first service container stops |
| [`watch`](compose_watch.md) | Watch build context for service and rebuild/refresh containers when files are updated |
### Options
| Name | Type | Default | Description |
|:-----------------------|:--------------|:--------|:----------------------------------------------------------------------------------------------------|
| `--all-resources` | | | Include all resources, even those not used by services |
| `--ansi` | `string` | `auto` | Control when to print ANSI control characters ("never"\|"always"\|"auto") |
| `--compatibility` | | | Run compose in backward compatibility mode |
| `--dry-run` | | | Execute command in dry run mode |
| `--env-file` | `stringArray` | | Specify an alternate environment file. |
| `--env-file` | `stringArray` | | Specify an alternate environment file |
| `-f`, `--file` | `stringArray` | | Compose configuration files |
| `--parallel` | `int` | `-1` | Control max parallelism, -1 for unlimited |
| `--profile` | `stringArray` | | Specify a profile to enable |
@@ -176,6 +177,9 @@ If flags are explicitly set on the command line, the associated environment vari
Setting the `COMPOSE_IGNORE_ORPHANS` environment variable to `true` stops docker compose from detecting orphaned
containers for the project.
Setting the `COMPOSE_MENU` environment variable to `false` disables the helper menu when running `docker compose up`
in attached mode. Alternatively, you can also run `docker compose up --menu=false` to disable the helper menu.
### Use Dry Run mode to test your command
Use `--dry-run` flag to test a command without changing your application stack state.

View File

@@ -1,7 +1,7 @@
# docker compose alpha dry-run
<!---MARKER_GEN_START-->
Dry run command allows you to test a command without applying changes.
Dry run command allows you to test a command without applying changes
<!---MARKER_GEN_END-->

View File

@@ -9,7 +9,7 @@ Publish compose application
|:--------------------------|:---------|:--------|:-------------------------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--oci-version` | `string` | | OCI Image/Artifact specification version (automatically determined by default) |
| `--resolve-image-digests` | | | Pin image tags to digests. |
| `--resolve-image-digests` | | | Pin image tags to digests |
<!---MARKER_GEN_END-->

View File

@@ -1,14 +1,14 @@
# docker compose alpha scale
<!---MARKER_GEN_START-->
Scale services.
Scale services
### Options
| Name | Type | Default | Description |
|:------------|:-----|:--------|:--------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--no-deps` | | | Don't start linked services |
| `--no-deps` | | | Don't start linked services |
<!---MARKER_GEN_END-->

View File

@@ -1,7 +1,7 @@
# docker compose attach
<!---MARKER_GEN_START-->
Attach local standard input, output, and error streams to a service's running container.
Attach local standard input, output, and error streams to a service's running container
### Options
@@ -11,8 +11,7 @@ Attach local standard input, output, and error streams to a service's running co
| `--dry-run` | | | Execute command in dry run mode |
| `--index` | `int` | `0` | index of the container if service has multiple replicas. |
| `--no-stdin` | | | Do not attach STDIN |
| `--sig-proxy` | | | Proxy all received signals to the process |
| `--sig-proxy` | `bool` | `true` | Proxy all received signals to the process |
<!---MARKER_GEN_END-->

View File

@@ -7,23 +7,23 @@ Build or rebuild services
| Name | Type | Default | Description |
|:----------------------|:--------------|:--------|:------------------------------------------------------------------------------------------------------------|
| `--build-arg` | `stringArray` | | Set build-time variables for services. |
| `--builder` | `string` | | Set builder to use. |
| `--build-arg` | `stringArray` | | Set build-time variables for services |
| `--builder` | `string` | | Set builder to use |
| `--dry-run` | | | Execute command in dry run mode |
| `-m`, `--memory` | `bytes` | `0` | Set memory limit for the build container. Not supported by BuildKit. |
| `--no-cache` | | | Do not use cache when building the image |
| `--pull` | | | Always attempt to pull a newer version of the image. |
| `--push` | | | Push service images. |
| `--pull` | | | Always attempt to pull a newer version of the image |
| `--push` | | | Push service images |
| `-q`, `--quiet` | | | Don't print anything to STDOUT |
| `--ssh` | `string` | | Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent) |
| `--with-dependencies` | | | Also build dependencies (transitively). |
| `--with-dependencies` | | | Also build dependencies (transitively) |
<!---MARKER_GEN_END-->
## Description
Services are built once and then tagged, by default as `project_service`.
Services are built once and then tagged, by default as `project-service`.
If the Compose file specifies an
[image](https://github.com/compose-spec/compose-spec/blob/master/spec.md#image) name,

View File

@@ -12,18 +12,20 @@ Parse, resolve and render compose file in canonical format
| Name | Type | Default | Description |
|:--------------------------|:---------|:--------|:----------------------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--environment` | | | Print environment used for interpolation. |
| `--format` | `string` | `yaml` | Format the output. Values: [yaml \| json] |
| `--hash` | `string` | | Print the service config hash, one per line. |
| `--images` | | | Print the image names, one per line. |
| `--no-consistency` | | | Don't check model consistency - warning: may produce invalid Compose output |
| `--no-interpolate` | | | Don't interpolate environment variables. |
| `--no-normalize` | | | Don't normalize compose model. |
| `--no-path-resolution` | | | Don't resolve file paths. |
| `--no-interpolate` | | | Don't interpolate environment variables |
| `--no-normalize` | | | Don't normalize compose model |
| `--no-path-resolution` | | | Don't resolve file paths |
| `-o`, `--output` | `string` | | Save to file (default to stdout) |
| `--profiles` | | | Print the profile names, one per line. |
| `-q`, `--quiet` | | | Only validate the configuration, don't print anything. |
| `--resolve-image-digests` | | | Pin image tags to digests. |
| `-q`, `--quiet` | | | Only validate the configuration, don't print anything |
| `--resolve-image-digests` | | | Pin image tags to digests |
| `--services` | | | Print the service names, one per line. |
| `--variables` | | | Print model variables and default values. |
| `--volumes` | | | Print the volume names, one per line. |

View File

@@ -10,7 +10,7 @@ Copy files/folders between a service container and the local filesystem
| `-a`, `--archive` | | | Archive mode (copy all uid/gid information) |
| `--dry-run` | | | Execute command in dry run mode |
| `-L`, `--follow-link` | | | Always follow symbol link in SRC_PATH |
| `--index` | `int` | `0` | index of the container if service has multiple replicas |
| `--index` | `int` | `0` | Index of the container if service has multiple replicas |
<!---MARKER_GEN_END-->

View File

@@ -1,19 +1,20 @@
# docker compose create
<!---MARKER_GEN_START-->
Creates containers for a service.
Creates containers for a service
### Options
| Name | Type | Default | Description |
|:-------------------|:--------------|:---------|:----------------------------------------------------------------------------------------------|
| `--build` | | | Build images before starting containers. |
| `--build` | | | Build images before starting containers |
| `--dry-run` | | | Execute command in dry run mode |
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed. |
| `--no-build` | | | Don't build an image, even if it's policy. |
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed |
| `--no-build` | | | Don't build an image, even if it's policy |
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never"\|"build") |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
| `--quiet-pull` | | | Pull without printing progress information |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file |
| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. |

View File

@@ -5,13 +5,13 @@ Stop and remove containers, networks
### Options
| Name | Type | Default | Description |
|:-------------------|:---------|:--------|:-------------------------------------------------------------------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
| `--rmi` | `string` | | Remove images used by services. "local" remove only images that don't have a custom tag ("local"\|"all") |
| `-t`, `--timeout` | `int` | `0` | Specify a shutdown timeout in seconds |
| `-v`, `--volumes` | | | Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers. |
| Name | Type | Default | Description |
|:-------------------|:---------|:--------|:------------------------------------------------------------------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file |
| `--rmi` | `string` | | Remove images used by services. "local" remove only images that don't have a custom tag ("local"\|"all") |
| `-t`, `--timeout` | `int` | `0` | Specify a shutdown timeout in seconds |
| `-v`, `--volumes` | | | Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers |
<!---MARKER_GEN_END-->

View File

@@ -1,7 +1,7 @@
# docker compose events
<!---MARKER_GEN_START-->
Receive real time events from containers.
Receive real time events from containers
### Options
@@ -33,4 +33,4 @@ With the `--json` flag, a json object is printed one per line with the format:
}
```
The events that can be received using this can be seen [here](https://docs.docker.com/engine/reference/commandline/system_events/#object-types).
The events that can be received using this can be seen [here](https://docs.docker.com/reference/cli/docker/system/events/#object-types).

View File

@@ -1,20 +1,20 @@
# docker compose exec
<!---MARKER_GEN_START-->
Execute a command in a running container.
Execute a command in a running container
### Options
| Name | Type | Default | Description |
|:------------------|:--------------|:--------|:---------------------------------------------------------------------------------|
| `-d`, `--detach` | | | Detached mode: Run command in the background. |
| `-d`, `--detach` | | | Detached mode: Run command in the background |
| `--dry-run` | | | Execute command in dry run mode |
| `-e`, `--env` | `stringArray` | | Set environment variables |
| `--index` | `int` | `0` | index of the container if service has multiple replicas |
| `-T`, `--no-TTY` | | | Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY. |
| `--privileged` | | | Give extended privileges to the process. |
| `-u`, `--user` | `string` | | Run the command as this user. |
| `-w`, `--workdir` | `string` | | Path to workdir directory for this command. |
| `--index` | `int` | `0` | Index of the container if service has multiple replicas |
| `-T`, `--no-TTY` | `bool` | `true` | Disable pseudo-TTY allocation. By default `docker compose exec` allocates a TTY. |
| `--privileged` | | | Give extended privileges to the process |
| `-u`, `--user` | `string` | | Run the command as this user |
| `-w`, `--workdir` | `string` | | Path to workdir directory for this command |
<!---MARKER_GEN_END-->

View File

@@ -5,11 +5,11 @@ List images used by the created containers
### Options
| Name | Type | Default | Description |
|:----------------|:---------|:--------|:--------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--format` | `string` | `table` | Format the output. Values: [table \| json]. |
| `-q`, `--quiet` | | | Only display IDs |
| Name | Type | Default | Description |
|:----------------|:---------|:--------|:-------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--format` | `string` | `table` | Format the output. Values: [table \| json] |
| `-q`, `--quiet` | | | Only display IDs |
<!---MARKER_GEN_END-->

View File

@@ -1,15 +1,15 @@
# docker compose kill
<!---MARKER_GEN_START-->
Force stop service containers.
Force stop service containers
### Options
| Name | Type | Default | Description |
|:-------------------|:---------|:----------|:----------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
| `-s`, `--signal` | `string` | `SIGKILL` | SIGNAL to send to the container. |
| Name | Type | Default | Description |
|:-------------------|:---------|:----------|:---------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file |
| `-s`, `--signal` | `string` | `SIGKILL` | SIGNAL to send to the container |
<!---MARKER_GEN_END-->

View File

@@ -8,13 +8,13 @@ View output from containers
| Name | Type | Default | Description |
|:---------------------|:---------|:--------|:-----------------------------------------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `-f`, `--follow` | | | Follow log output. |
| `-f`, `--follow` | | | Follow log output |
| `--index` | `int` | `0` | index of the container if service has multiple replicas |
| `--no-color` | | | Produce monochrome output. |
| `--no-log-prefix` | | | Don't print prefix in logs. |
| `--no-color` | | | Produce monochrome output |
| `--no-log-prefix` | | | Don't print prefix in logs |
| `--since` | `string` | | Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes) |
| `-n`, `--tail` | `string` | `all` | Number of lines to show from the end of the logs for each container. |
| `-t`, `--timestamps` | | | Show timestamps. |
| `-n`, `--tail` | `string` | `all` | Number of lines to show from the end of the logs for each container |
| `-t`, `--timestamps` | | | Show timestamps |
| `--until` | `string` | | Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes) |
@@ -22,4 +22,4 @@ View output from containers
## Description
Displays log output from services.
Displays log output from services

View File

@@ -5,17 +5,17 @@ List running compose projects
### Options
| Name | Type | Default | Description |
|:----------------|:---------|:--------|:--------------------------------------------|
| `-a`, `--all` | | | Show all stopped Compose projects |
| `--dry-run` | | | Execute command in dry run mode |
| `--filter` | `filter` | | Filter output based on conditions provided. |
| `--format` | `string` | `table` | Format the output. Values: [table \| json]. |
| `-q`, `--quiet` | | | Only display IDs. |
| Name | Type | Default | Description |
|:----------------|:---------|:--------|:-------------------------------------------|
| `-a`, `--all` | | | Show all stopped Compose projects |
| `--dry-run` | | | Execute command in dry run mode |
| `--filter` | `filter` | | Filter output based on conditions provided |
| `--format` | `string` | `table` | Format the output. Values: [table \| json] |
| `-q`, `--quiet` | | | Only display IDs |
<!---MARKER_GEN_END-->
## Description
Lists running Compose projects.
Lists running Compose projects

View File

@@ -1,14 +1,14 @@
# docker compose port
<!---MARKER_GEN_START-->
Print the public port for a port binding.
Print the public port for a port binding
### Options
| Name | Type | Default | Description |
|:-------------|:---------|:--------|:--------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--index` | `int` | `0` | index of the container if service has multiple replicas |
| `--index` | `int` | `0` | Index of the container if service has multiple replicas |
| `--protocol` | `string` | `tcp` | tcp or udp |
@@ -16,4 +16,4 @@ Print the public port for a port binding.
## Description
Prints the public port for a port binding.
Prints the public port for a port binding

View File

@@ -9,10 +9,10 @@ List containers
|:----------------------|:--------------|:--------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-a`, `--all` | | | Show all stopped containers (including those created by the run command) |
| `--dry-run` | | | Execute command in dry run mode |
| [`--filter`](#filter) | `string` | | Filter services by a property (supported filters: status). |
| [`--filter`](#filter) | `string` | | Filter services by a property (supported filters: status) |
| [`--format`](#format) | `string` | `table` | Format output using a custom template:<br>'table': Print output in table format with column headers (default)<br>'table TEMPLATE': Print output in table format using the given Go template<br>'json': Print in JSON format<br>'TEMPLATE': Print output using the given Go template.<br>Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates |
| `--no-trunc` | | | Don't truncate output |
| `--orphans` | | | Include orphaned services (not declared by project) |
| `--orphans` | `bool` | `true` | Include orphaned services (not declared by project) |
| `-q`, `--quiet` | | | Only display IDs |
| `--services` | | | Display services |
| [`--status`](#status) | `stringArray` | | Filter services by status. Values: [paused \| restarting \| removing \| running \| dead \| created \| exited] |

View File

@@ -5,22 +5,21 @@ Pull service images
### Options
| Name | Type | Default | Description |
|:-------------------------|:---------|:--------|:--------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--ignore-buildable` | | | Ignore images that can be built. |
| `--ignore-pull-failures` | | | Pull what it can and ignores images with pull failures. |
| `--include-deps` | | | Also pull services declared as dependencies. |
| `--policy` | `string` | | Apply pull policy ("missing"\|"always"). |
| `-q`, `--quiet` | | | Pull without printing progress information. |
| Name | Type | Default | Description |
|:-------------------------|:---------|:--------|:-------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--ignore-buildable` | | | Ignore images that can be built |
| `--ignore-pull-failures` | | | Pull what it can and ignores images with pull failures |
| `--include-deps` | | | Also pull services declared as dependencies |
| `--policy` | `string` | | Apply pull policy ("missing"\|"always") |
| `-q`, `--quiet` | | | Pull without printing progress information |
<!---MARKER_GEN_END-->
## Description
Pulls an image associated with a service defined in a `compose.yaml` file, but does not start containers based on
those images.
Pulls an image associated with a service defined in a `compose.yaml` file, but does not start containers based on those images
## Examples

View File

@@ -8,7 +8,7 @@ Restart service containers
| Name | Type | Default | Description |
|:------------------|:------|:--------|:--------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--no-deps` | | | Don't restart dependent services. |
| `--no-deps` | | | Don't restart dependent services |
| `-t`, `--timeout` | `int` | `0` | Specify a shutdown timeout in seconds |

View File

@@ -1,33 +1,33 @@
# docker compose run
<!---MARKER_GEN_START-->
Run a one-off command on a service.
Run a one-off command on a service
### Options
| Name | Type | Default | Description |
|:------------------------|:--------------|:--------|:----------------------------------------------------------------------------------|
| `--build` | | | Build image before starting container. |
| `--cap-add` | `list` | | Add Linux capabilities |
| `--cap-drop` | `list` | | Drop Linux capabilities |
| `-d`, `--detach` | | | Run container in background and print container ID |
| `--dry-run` | | | Execute command in dry run mode |
| `--entrypoint` | `string` | | Override the entrypoint of the image |
| `-e`, `--env` | `stringArray` | | Set environment variables |
| `-i`, `--interactive` | | | Keep STDIN open even if not attached. |
| `-l`, `--label` | `stringArray` | | Add or override a label |
| `--name` | `string` | | Assign a name to the container |
| `-T`, `--no-TTY` | | | Disable pseudo-TTY allocation (default: auto-detected). |
| `--no-deps` | | | Don't start linked services. |
| `-p`, `--publish` | `stringArray` | | Publish a container's port(s) to the host. |
| `--quiet-pull` | | | Pull without printing progress information. |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
| `--rm` | | | Automatically remove the container when it exits |
| `-P`, `--service-ports` | | | Run command with all service's ports enabled and mapped to the host. |
| `--use-aliases` | | | Use the service's network useAliases in the network(s) the container connects to. |
| `-u`, `--user` | `string` | | Run as specified username or uid |
| `-v`, `--volume` | `stringArray` | | Bind mount a volume. |
| `-w`, `--workdir` | `string` | | Working directory inside the container |
| Name | Type | Default | Description |
|:------------------------|:--------------|:--------|:---------------------------------------------------------------------------------|
| `--build` | | | Build image before starting container |
| `--cap-add` | `list` | | Add Linux capabilities |
| `--cap-drop` | `list` | | Drop Linux capabilities |
| `-d`, `--detach` | | | Run container in background and print container ID |
| `--dry-run` | | | Execute command in dry run mode |
| `--entrypoint` | `string` | | Override the entrypoint of the image |
| `-e`, `--env` | `stringArray` | | Set environment variables |
| `-i`, `--interactive` | `bool` | `true` | Keep STDIN open even if not attached |
| `-l`, `--label` | `stringArray` | | Add or override a label |
| `--name` | `string` | | Assign a name to the container |
| `-T`, `--no-TTY` | `bool` | `true` | Disable pseudo-TTY allocation (default: auto-detected) |
| `--no-deps` | | | Don't start linked services |
| `-p`, `--publish` | `stringArray` | | Publish a container's port(s) to the host |
| `--quiet-pull` | | | Pull without printing progress information |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file |
| `--rm` | | | Automatically remove the container when it exits |
| `-P`, `--service-ports` | | | Run command with all service's ports enabled and mapped to the host |
| `--use-aliases` | | | Use the service's network useAliases in the network(s) the container connects to |
| `-u`, `--user` | `string` | | Run as specified username or uid |
| `-v`, `--volume` | `stringArray` | | Bind mount a volume |
| `-w`, `--workdir` | `string` | | Working directory inside the container |
<!---MARKER_GEN_END-->

View File

@@ -8,7 +8,7 @@ Scale services
| Name | Type | Default | Description |
|:------------|:-----|:--------|:--------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `--no-deps` | | | Don't start linked services. |
| `--no-deps` | | | Don't start linked services |
<!---MARKER_GEN_END-->

View File

@@ -14,4 +14,4 @@ Start services
## Description
Starts existing containers for a service.
Starts existing containers for a service

View File

@@ -14,7 +14,7 @@ Display the running processes
## Description
Displays the running processes.
Displays the running processes
## Examples

View File

@@ -14,4 +14,4 @@ Unpause services
## Description
Unpauses paused containers of a service.
Unpauses paused containers of a service

View File

@@ -5,33 +5,36 @@ Create and start containers
### Options
| Name | Type | Default | Description |
|:-----------------------------|:--------------|:---------|:---------------------------------------------------------------------------------------------------------|
| `--abort-on-container-exit` | | | Stops all containers if any container was stopped. Incompatible with -d |
| `--always-recreate-deps` | | | Recreate dependent containers. Incompatible with --no-recreate. |
| `--attach` | `stringArray` | | Restrict attaching to the specified services. Incompatible with --attach-dependencies. |
| `--attach-dependencies` | | | Automatically attach to log output of dependent services. |
| `--build` | | | Build images before starting containers. |
| `-d`, `--detach` | | | Detached mode: Run containers in the background |
| `--dry-run` | | | Execute command in dry run mode |
| `--exit-code-from` | `string` | | Return the exit code of the selected service container. Implies --abort-on-container-exit |
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed. |
| `--no-attach` | `stringArray` | | Do not attach (stream logs) to the specified services. |
| `--no-build` | | | Don't build an image, even if it's policy. |
| `--no-color` | | | Produce monochrome output. |
| `--no-deps` | | | Don't start linked services. |
| `--no-log-prefix` | | | Don't print prefix in logs. |
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
| `--no-start` | | | Don't start the services after creating them. |
| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never") |
| `--quiet-pull` | | | Pull without printing progress information. |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file. |
| `-V`, `--renew-anon-volumes` | | | Recreate anonymous volumes instead of retrieving data from the previous containers. |
| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. |
| `-t`, `--timeout` | `int` | `0` | Use this timeout in seconds for container shutdown when attached or when containers are already running. |
| `--timestamps` | | | Show timestamps. |
| `--wait` | | | Wait for services to be running\|healthy. Implies detached mode. |
| `--wait-timeout` | `int` | `0` | Maximum duration to wait for the project to be running\|healthy. |
| Name | Type | Default | Description |
|:-------------------------------|:--------------|:---------|:----------------------------------------------------------------------------------------------------------------------------------------------------|
| `--abort-on-container-exit` | | | Stops all containers if any container was stopped. Incompatible with -d |
| `--abort-on-container-failure` | | | Stops all containers if any container exited with failure. Incompatible with -d |
| `--always-recreate-deps` | | | Recreate dependent containers. Incompatible with --no-recreate. |
| `--attach` | `stringArray` | | Restrict attaching to the specified services. Incompatible with --attach-dependencies. |
| `--attach-dependencies` | | | Automatically attach to log output of dependent services |
| `--build` | | | Build images before starting containers |
| `-d`, `--detach` | | | Detached mode: Run containers in the background |
| `--dry-run` | | | Execute command in dry run mode |
| `--exit-code-from` | `string` | | Return the exit code of the selected service container. Implies --abort-on-container-exit |
| `--force-recreate` | | | Recreate containers even if their configuration and image haven't changed |
| `--menu` | | | Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var. |
| `--no-attach` | `stringArray` | | Do not attach (stream logs) to the specified services |
| `--no-build` | | | Don't build an image, even if it's policy |
| `--no-color` | | | Produce monochrome output |
| `--no-deps` | | | Don't start linked services |
| `--no-log-prefix` | | | Don't print prefix in logs |
| `--no-recreate` | | | If containers already exist, don't recreate them. Incompatible with --force-recreate. |
| `--no-start` | | | Don't start the services after creating them |
| `--pull` | `string` | `policy` | Pull image before running ("always"\|"missing"\|"never") |
| `--quiet-pull` | | | Pull without printing progress information |
| `--remove-orphans` | | | Remove containers for services not defined in the Compose file |
| `-V`, `--renew-anon-volumes` | | | Recreate anonymous volumes instead of retrieving data from the previous containers |
| `--scale` | `stringArray` | | Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present. |
| `-t`, `--timeout` | `int` | `0` | Use this timeout in seconds for container shutdown when attached or when containers are already running |
| `--timestamps` | | | Show timestamps |
| `--wait` | | | Wait for services to be running\|healthy. Implies detached mode. |
| `--wait-timeout` | `int` | `0` | Maximum duration to wait for the project to be running\|healthy |
| `-w`, `--watch` | | | Watch source code and rebuild/refresh containers when files are updated. |
<!---MARKER_GEN_END-->

View File

@@ -9,7 +9,7 @@ Show the Docker Compose version information
|:-----------------|:---------|:--------|:---------------------------------------------------------------|
| `--dry-run` | | | Execute command in dry run mode |
| `-f`, `--format` | `string` | | Format the output. Values: [pretty \| json]. (Default: pretty) |
| `--short` | | | Shows only Compose's version number. |
| `--short` | | | Shows only Compose's version number |
<!---MARKER_GEN_END-->

View File

@@ -118,6 +118,9 @@ long: |-
Setting the `COMPOSE_IGNORE_ORPHANS` environment variable to `true` stops docker compose from detecting orphaned
containers for the project.
Setting the `COMPOSE_MENU` environment variable to `false` disables the helper menu when running `docker compose up`
in attached mode. Alternatively, you can also run `docker compose up --menu=false` to disable the helper menu.
### Use Dry Run mode to test your command
Use `--dry-run` flag to test a command without changing your application stack state.
@@ -208,6 +211,16 @@ clink:
- docker_compose_wait.yaml
- docker_compose_watch.yaml
options:
- option: all-resources
value_type: bool
default_value: "false"
description: Include all resources, even those not used by services
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: ansi
value_type: string
default_value: auto
@@ -242,7 +255,7 @@ options:
- option: env-file
value_type: stringArray
default_value: '[]'
description: Specify an alternate environment file.
description: Specify an alternate environment file
deprecated: false
hidden: false
experimental: false

View File

@@ -18,7 +18,7 @@ options:
- option: resolve-image-digests
value_type: bool
default_value: "false"
description: Pin image tags to digests.
description: Pin image tags to digests
deprecated: false
hidden: false
experimental: false

View File

@@ -1,8 +1,8 @@
command: docker compose attach
short: |
Attach local standard input, output, and error streams to a service's running container.
Attach local standard input, output, and error streams to a service's running container
long: |
Attach local standard input, output, and error streams to a service's running container.
Attach local standard input, output, and error streams to a service's running container
usage: docker compose attach [OPTIONS] SERVICE
pname: docker compose
plink: docker_compose.yaml

View File

@@ -1,7 +1,7 @@
command: docker compose build
short: Build or rebuild services
long: |-
Services are built once and then tagged, by default as `project_service`.
Services are built once and then tagged, by default as `project-service`.
If the Compose file specifies an
[image](https://github.com/compose-spec/compose-spec/blob/master/spec.md#image) name,
@@ -17,7 +17,7 @@ options:
- option: build-arg
value_type: stringArray
default_value: '[]'
description: Set build-time variables for services.
description: Set build-time variables for services
deprecated: false
hidden: false
experimental: false
@@ -26,7 +26,7 @@ options:
swarm: false
- option: builder
value_type: string
description: Set builder to use.
description: Set builder to use
deprecated: false
hidden: false
experimental: false
@@ -109,7 +109,7 @@ options:
- option: pull
value_type: bool
default_value: "false"
description: Always attempt to pull a newer version of the image.
description: Always attempt to pull a newer version of the image
deprecated: false
hidden: false
experimental: false
@@ -119,7 +119,7 @@ options:
- option: push
value_type: bool
default_value: "false"
description: Push service images.
description: Push service images
deprecated: false
hidden: false
experimental: false
@@ -150,7 +150,7 @@ options:
- option: with-dependencies
value_type: bool
default_value: "false"
description: Also build dependencies (transitively).
description: Also build dependencies (transitively)
deprecated: false
hidden: false
experimental: false

View File

@@ -9,6 +9,16 @@ usage: docker compose config [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml
options:
- option: environment
value_type: bool
default_value: "false"
description: Print environment used for interpolation.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: format
value_type: string
default_value: yaml
@@ -52,7 +62,7 @@ options:
- option: no-interpolate
value_type: bool
default_value: "false"
description: Don't interpolate environment variables.
description: Don't interpolate environment variables
deprecated: false
hidden: false
experimental: false
@@ -62,7 +72,7 @@ options:
- option: no-normalize
value_type: bool
default_value: "false"
description: Don't normalize compose model.
description: Don't normalize compose model
deprecated: false
hidden: false
experimental: false
@@ -72,7 +82,7 @@ options:
- option: no-path-resolution
value_type: bool
default_value: "false"
description: Don't resolve file paths.
description: Don't resolve file paths
deprecated: false
hidden: false
experimental: false
@@ -103,7 +113,7 @@ options:
shorthand: q
value_type: bool
default_value: "false"
description: Only validate the configuration, don't print anything.
description: Only validate the configuration, don't print anything
deprecated: false
hidden: false
experimental: false
@@ -113,7 +123,7 @@ options:
- option: resolve-image-digests
value_type: bool
default_value: "false"
description: Pin image tags to digests.
description: Pin image tags to digests
deprecated: false
hidden: false
experimental: false
@@ -130,6 +140,16 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: variables
value_type: bool
default_value: "false"
description: Print model variables and default values.
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: volumes
value_type: bool
default_value: "false"

View File

@@ -10,7 +10,7 @@ options:
- option: all
value_type: bool
default_value: "false"
description: copy to all the containers of the service.
description: Copy to all the containers of the service
deprecated: true
hidden: true
experimental: false
@@ -42,7 +42,7 @@ options:
- option: index
value_type: int
default_value: "0"
description: index of the container if service has multiple replicas
description: Index of the container if service has multiple replicas
deprecated: false
hidden: false
experimental: false

View File

@@ -1,6 +1,6 @@
command: docker compose create
short: Creates containers for a service.
long: Creates containers for a service.
short: Creates containers for a service
long: Creates containers for a service
usage: docker compose create [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml
@@ -8,7 +8,7 @@ options:
- option: build
value_type: bool
default_value: "false"
description: Build images before starting containers.
description: Build images before starting containers
deprecated: false
hidden: false
experimental: false
@@ -19,7 +19,7 @@ options:
value_type: bool
default_value: "false"
description: |
Recreate containers even if their configuration and image haven't changed.
Recreate containers even if their configuration and image haven't changed
deprecated: false
hidden: false
experimental: false
@@ -29,7 +29,7 @@ options:
- option: no-build
value_type: bool
default_value: "false"
description: Don't build an image, even if it's policy.
description: Don't build an image, even if it's policy
deprecated: false
hidden: false
experimental: false
@@ -57,10 +57,20 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: quiet-pull
value_type: bool
default_value: "false"
description: Pull without printing progress information
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: remove-orphans
value_type: bool
default_value: "false"
description: Remove containers for services not defined in the Compose file.
description: Remove containers for services not defined in the Compose file
deprecated: false
hidden: false
experimental: false

View File

@@ -21,7 +21,7 @@ options:
- option: remove-orphans
value_type: bool
default_value: "false"
description: Remove containers for services not defined in the Compose file.
description: Remove containers for services not defined in the Compose file
deprecated: false
hidden: false
experimental: false
@@ -54,7 +54,7 @@ options:
value_type: bool
default_value: "false"
description: |
Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers.
Remove named volumes declared in the "volumes" section of the Compose file and anonymous volumes attached to containers
deprecated: false
hidden: false
experimental: false

View File

@@ -1,5 +1,5 @@
command: docker compose events
short: Receive real time events from containers.
short: Receive real time events from containers
long: |-
Stream container events for every container in the project.
@@ -19,7 +19,7 @@ long: |-
}
```
The events that can be received using this can be seen [here](/engine/reference/commandline/system_events/#object-types).
The events that can be received using this can be seen [here](/reference/cli/docker/system/events/#object-types).
usage: docker compose events [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml

View File

@@ -1,5 +1,5 @@
command: docker compose exec
short: Execute a command in a running container.
short: Execute a command in a running container
long: |-
This is the equivalent of `docker exec` targeting a Compose service.
@@ -13,7 +13,7 @@ options:
shorthand: d
value_type: bool
default_value: "false"
description: 'Detached mode: Run command in the background.'
description: 'Detached mode: Run command in the background'
deprecated: false
hidden: false
experimental: false
@@ -34,7 +34,7 @@ options:
- option: index
value_type: int
default_value: "0"
description: index of the container if service has multiple replicas
description: Index of the container if service has multiple replicas
deprecated: false
hidden: false
experimental: false
@@ -45,7 +45,7 @@ options:
shorthand: i
value_type: bool
default_value: "true"
description: Keep STDIN open even if not attached.
description: Keep STDIN open even if not attached
deprecated: false
hidden: true
experimental: false
@@ -67,7 +67,7 @@ options:
- option: privileged
value_type: bool
default_value: "false"
description: Give extended privileges to the process.
description: Give extended privileges to the process
deprecated: false
hidden: false
experimental: false
@@ -78,7 +78,7 @@ options:
shorthand: t
value_type: bool
default_value: "true"
description: Allocate a pseudo-TTY.
description: Allocate a pseudo-TTY
deprecated: false
hidden: true
experimental: false
@@ -88,7 +88,7 @@ options:
- option: user
shorthand: u
value_type: string
description: Run the command as this user.
description: Run the command as this user
deprecated: false
hidden: false
experimental: false
@@ -98,7 +98,7 @@ options:
- option: workdir
shorthand: w
value_type: string
description: Path to workdir directory for this command.
description: Path to workdir directory for this command
deprecated: false
hidden: false
experimental: false

View File

@@ -8,7 +8,7 @@ options:
- option: format
value_type: string
default_value: table
description: 'Format the output. Values: [table | json].'
description: 'Format the output. Values: [table | json]'
deprecated: false
hidden: false
experimental: false

View File

@@ -1,5 +1,5 @@
command: docker compose kill
short: Force stop service containers.
short: Force stop service containers
long: |-
Forces running containers to stop by sending a `SIGKILL` signal. Optionally the signal can be passed, for example:
@@ -13,7 +13,7 @@ options:
- option: remove-orphans
value_type: bool
default_value: "false"
description: Remove containers for services not defined in the Compose file.
description: Remove containers for services not defined in the Compose file
deprecated: false
hidden: false
experimental: false
@@ -24,7 +24,7 @@ options:
shorthand: s
value_type: string
default_value: SIGKILL
description: SIGNAL to send to the container.
description: SIGNAL to send to the container
deprecated: false
hidden: false
experimental: false

View File

@@ -1,6 +1,6 @@
command: docker compose logs
short: View output from containers
long: Displays log output from services.
long: Displays log output from services
usage: docker compose logs [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml
@@ -9,7 +9,7 @@ options:
shorthand: f
value_type: bool
default_value: "false"
description: Follow log output.
description: Follow log output
deprecated: false
hidden: false
experimental: false
@@ -29,7 +29,7 @@ options:
- option: no-color
value_type: bool
default_value: "false"
description: Produce monochrome output.
description: Produce monochrome output
deprecated: false
hidden: false
experimental: false
@@ -39,7 +39,7 @@ options:
- option: no-log-prefix
value_type: bool
default_value: "false"
description: Don't print prefix in logs.
description: Don't print prefix in logs
deprecated: false
hidden: false
experimental: false
@@ -61,7 +61,7 @@ options:
value_type: string
default_value: all
description: |
Number of lines to show from the end of the logs for each container.
Number of lines to show from the end of the logs for each container
deprecated: false
hidden: false
experimental: false
@@ -72,7 +72,7 @@ options:
shorthand: t
value_type: bool
default_value: "false"
description: Show timestamps.
description: Show timestamps
deprecated: false
hidden: false
experimental: false

View File

@@ -1,6 +1,6 @@
command: docker compose ls
short: List running compose projects
long: Lists running Compose projects.
long: Lists running Compose projects
usage: docker compose ls [OPTIONS]
pname: docker compose
plink: docker_compose.yaml
@@ -18,7 +18,7 @@ options:
swarm: false
- option: filter
value_type: filter
description: Filter output based on conditions provided.
description: Filter output based on conditions provided
deprecated: false
hidden: false
experimental: false
@@ -28,7 +28,7 @@ options:
- option: format
value_type: string
default_value: table
description: 'Format the output. Values: [table | json].'
description: 'Format the output. Values: [table | json]'
deprecated: false
hidden: false
experimental: false
@@ -39,7 +39,7 @@ options:
shorthand: q
value_type: bool
default_value: "false"
description: Only display IDs.
description: Only display IDs
deprecated: false
hidden: false
experimental: false

View File

@@ -1,6 +1,6 @@
command: docker compose port
short: Print the public port for a port binding.
long: Prints the public port for a port binding.
short: Print the public port for a port binding
long: Prints the public port for a port binding
usage: docker compose port [OPTIONS] SERVICE PRIVATE_PORT
pname: docker compose
plink: docker_compose.yaml
@@ -8,7 +8,7 @@ options:
- option: index
value_type: int
default_value: "0"
description: index of the container if service has multiple replicas
description: Index of the container if service has multiple replicas
deprecated: false
hidden: false
experimental: false

View File

@@ -35,7 +35,7 @@ options:
swarm: false
- option: filter
value_type: string
description: 'Filter services by a property (supported filters: status).'
description: 'Filter services by a property (supported filters: status)'
details_url: '#filter'
deprecated: false
hidden: false

View File

@@ -1,8 +1,7 @@
command: docker compose pull
short: Pull service images
long: |-
Pulls an image associated with a service defined in a `compose.yaml` file, but does not start containers based on
those images.
long: |
Pulls an image associated with a service defined in a `compose.yaml` file, but does not start containers based on those images
usage: docker compose pull [OPTIONS] [SERVICE...]
pname: docker compose
plink: docker_compose.yaml
@@ -10,7 +9,7 @@ options:
- option: ignore-buildable
value_type: bool
default_value: "false"
description: Ignore images that can be built.
description: Ignore images that can be built
deprecated: false
hidden: false
experimental: false
@@ -20,7 +19,7 @@ options:
- option: ignore-pull-failures
value_type: bool
default_value: "false"
description: Pull what it can and ignores images with pull failures.
description: Pull what it can and ignores images with pull failures
deprecated: false
hidden: false
experimental: false
@@ -30,7 +29,7 @@ options:
- option: include-deps
value_type: bool
default_value: "false"
description: Also pull services declared as dependencies.
description: Also pull services declared as dependencies
deprecated: false
hidden: false
experimental: false
@@ -40,7 +39,7 @@ options:
- option: no-parallel
value_type: bool
default_value: "true"
description: DEPRECATED disable parallel pulling.
description: DEPRECATED disable parallel pulling
deprecated: false
hidden: true
experimental: false
@@ -50,7 +49,7 @@ options:
- option: parallel
value_type: bool
default_value: "true"
description: DEPRECATED pull multiple images in parallel.
description: DEPRECATED pull multiple images in parallel
deprecated: false
hidden: true
experimental: false
@@ -59,7 +58,7 @@ options:
swarm: false
- option: policy
value_type: string
description: Apply pull policy ("missing"|"always").
description: Apply pull policy ("missing"|"always")
deprecated: false
hidden: false
experimental: false
@@ -70,7 +69,7 @@ options:
shorthand: q
value_type: bool
default_value: "false"
description: Pull without printing progress information.
description: Pull without printing progress information
deprecated: false
hidden: false
experimental: false

View File

@@ -18,7 +18,7 @@ options:
- option: no-deps
value_type: bool
default_value: "false"
description: Don't restart dependent services.
description: Don't restart dependent services
deprecated: false
hidden: false
experimental: false

View File

@@ -1,5 +1,5 @@
command: docker compose run
short: Run a one-off command on a service.
short: Run a one-off command on a service
long: |-
Runs a one-time command against a service.
@@ -61,7 +61,7 @@ options:
- option: build
value_type: bool
default_value: "false"
description: Build image before starting container.
description: Build image before starting container
deprecated: false
hidden: false
experimental: false
@@ -121,7 +121,7 @@ options:
shorthand: i
value_type: bool
default_value: "true"
description: Keep STDIN open even if not attached.
description: Keep STDIN open even if not attached
deprecated: false
hidden: false
experimental: false
@@ -152,7 +152,7 @@ options:
shorthand: T
value_type: bool
default_value: "true"
description: 'Disable pseudo-TTY allocation (default: auto-detected).'
description: 'Disable pseudo-TTY allocation (default: auto-detected)'
deprecated: false
hidden: false
experimental: false
@@ -162,7 +162,7 @@ options:
- option: no-deps
value_type: bool
default_value: "false"
description: Don't start linked services.
description: Don't start linked services
deprecated: false
hidden: false
experimental: false
@@ -173,7 +173,7 @@ options:
shorthand: p
value_type: stringArray
default_value: '[]'
description: Publish a container's port(s) to the host.
description: Publish a container's port(s) to the host
deprecated: false
hidden: false
experimental: false
@@ -183,7 +183,7 @@ options:
- option: quiet-pull
value_type: bool
default_value: "false"
description: Pull without printing progress information.
description: Pull without printing progress information
deprecated: false
hidden: false
experimental: false
@@ -193,7 +193,7 @@ options:
- option: remove-orphans
value_type: bool
default_value: "false"
description: Remove containers for services not defined in the Compose file.
description: Remove containers for services not defined in the Compose file
deprecated: false
hidden: false
experimental: false
@@ -215,7 +215,7 @@ options:
value_type: bool
default_value: "false"
description: |
Run command with all service's ports enabled and mapped to the host.
Run command with all service's ports enabled and mapped to the host
deprecated: false
hidden: false
experimental: false
@@ -226,7 +226,7 @@ options:
shorthand: t
value_type: bool
default_value: "true"
description: Allocate a pseudo-TTY.
description: Allocate a pseudo-TTY
deprecated: false
hidden: true
experimental: false
@@ -237,7 +237,7 @@ options:
value_type: bool
default_value: "false"
description: |
Use the service's network useAliases in the network(s) the container connects to.
Use the service's network useAliases in the network(s) the container connects to
deprecated: false
hidden: false
experimental: false
@@ -258,7 +258,7 @@ options:
shorthand: v
value_type: stringArray
default_value: '[]'
description: Bind mount a volume.
description: Bind mount a volume
deprecated: false
hidden: false
experimental: false

View File

@@ -8,7 +8,7 @@ options:
- option: no-deps
value_type: bool
default_value: "false"
description: Don't start linked services.
description: Don't start linked services
deprecated: false
hidden: false
experimental: false

View File

@@ -1,6 +1,6 @@
command: docker compose start
short: Start services
long: Starts existing containers for a service.
long: Starts existing containers for a service
usage: docker compose start [SERVICE...]
pname: docker compose
plink: docker_compose.yaml

View File

@@ -1,6 +1,6 @@
command: docker compose top
short: Display the running processes
long: Displays the running processes.
long: Displays the running processes
usage: docker compose top [SERVICES...]
pname: docker compose
plink: docker_compose.yaml

View File

@@ -1,6 +1,6 @@
command: docker compose unpause
short: Unpause services
long: Unpauses paused containers of a service.
long: Unpauses paused containers of a service
usage: docker compose unpause [SERVICE...]
pname: docker compose
plink: docker_compose.yaml

View File

@@ -35,6 +35,17 @@ options:
experimentalcli: false
kubernetes: false
swarm: false
- option: abort-on-container-failure
value_type: bool
default_value: "false"
description: |
Stops all containers if any container exited with failure. Incompatible with -d
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: always-recreate-deps
value_type: bool
default_value: "false"
@@ -59,7 +70,7 @@ options:
- option: attach-dependencies
value_type: bool
default_value: "false"
description: Automatically attach to log output of dependent services.
description: Automatically attach to log output of dependent services
deprecated: false
hidden: false
experimental: false
@@ -69,7 +80,7 @@ options:
- option: build
value_type: bool
default_value: "false"
description: Build images before starting containers.
description: Build images before starting containers
deprecated: false
hidden: false
experimental: false
@@ -101,7 +112,18 @@ options:
value_type: bool
default_value: "false"
description: |
Recreate containers even if their configuration and image haven't changed.
Recreate containers even if their configuration and image haven't changed
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: menu
value_type: bool
default_value: "false"
description: |
Enable interactive shortcuts when running attached. Incompatible with --detach. Can also be enable/disable by setting COMPOSE_MENU environment var.
deprecated: false
hidden: false
experimental: false
@@ -111,7 +133,7 @@ options:
- option: no-attach
value_type: stringArray
default_value: '[]'
description: Do not attach (stream logs) to the specified services.
description: Do not attach (stream logs) to the specified services
deprecated: false
hidden: false
experimental: false
@@ -121,7 +143,7 @@ options:
- option: no-build
value_type: bool
default_value: "false"
description: Don't build an image, even if it's policy.
description: Don't build an image, even if it's policy
deprecated: false
hidden: false
experimental: false
@@ -131,7 +153,7 @@ options:
- option: no-color
value_type: bool
default_value: "false"
description: Produce monochrome output.
description: Produce monochrome output
deprecated: false
hidden: false
experimental: false
@@ -141,7 +163,7 @@ options:
- option: no-deps
value_type: bool
default_value: "false"
description: Don't start linked services.
description: Don't start linked services
deprecated: false
hidden: false
experimental: false
@@ -151,7 +173,7 @@ options:
- option: no-log-prefix
value_type: bool
default_value: "false"
description: Don't print prefix in logs.
description: Don't print prefix in logs
deprecated: false
hidden: false
experimental: false
@@ -172,7 +194,7 @@ options:
- option: no-start
value_type: bool
default_value: "false"
description: Don't start the services after creating them.
description: Don't start the services after creating them
deprecated: false
hidden: false
experimental: false
@@ -192,7 +214,7 @@ options:
- option: quiet-pull
value_type: bool
default_value: "false"
description: Pull without printing progress information.
description: Pull without printing progress information
deprecated: false
hidden: false
experimental: false
@@ -202,7 +224,7 @@ options:
- option: remove-orphans
value_type: bool
default_value: "false"
description: Remove containers for services not defined in the Compose file.
description: Remove containers for services not defined in the Compose file
deprecated: false
hidden: false
experimental: false
@@ -214,7 +236,7 @@ options:
value_type: bool
default_value: "false"
description: |
Recreate anonymous volumes instead of retrieving data from the previous containers.
Recreate anonymous volumes instead of retrieving data from the previous containers
deprecated: false
hidden: false
experimental: false
@@ -237,7 +259,7 @@ options:
value_type: int
default_value: "0"
description: |
Use this timeout in seconds for container shutdown when attached or when containers are already running.
Use this timeout in seconds for container shutdown when attached or when containers are already running
deprecated: false
hidden: false
experimental: false
@@ -247,7 +269,7 @@ options:
- option: timestamps
value_type: bool
default_value: "false"
description: Show timestamps.
description: Show timestamps
deprecated: false
hidden: false
experimental: false
@@ -267,7 +289,19 @@ options:
- option: wait-timeout
value_type: int
default_value: "0"
description: Maximum duration to wait for the project to be running|healthy.
description: Maximum duration to wait for the project to be running|healthy
deprecated: false
hidden: false
experimental: false
experimentalcli: false
kubernetes: false
swarm: false
- option: watch
shorthand: w
value_type: bool
default_value: "false"
description: |
Watch source code and rebuild/refresh containers when files are updated.
deprecated: false
hidden: false
experimental: false

Some files were not shown because too many files have changed in this diff Show More