Compare commits

..

102 Commits
1.28.5 ... v1

Author SHA1 Message Date
aevesdocker
0d4edbbd19 Change links and add versioning information
Signed-off-by: aevesdocker <allie.sadler@docker.com>
2024-05-01 14:52:41 +02:00
aevesdocker
fe42107f41 Add legacy reference files
Signed-off-by: aevesdocker <allie.sadler@docker.com>
2024-05-01 14:52:41 +02:00
Laura Brehm
30fcb72cf3 Merge pull request #9625 from laurazard/master
Update README.md of V1 branch to warn about V1 end-of-life
2022-07-04 19:45:45 +01:00
Laura Brehm
db94eb0c26 Add end-of-life message to issue templates
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-07-04 17:57:08 +01:00
Laura Brehm
c9527747eb Change wording about V2 GA being on the way for consistency.
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-07-04 17:43:50 +01:00
Laura Brehm
58dc3ad3c1 Update README.md of V1 branch to warn about V1 end-of-life
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-07-04 17:19:33 +01:00
Guillaume Lours
9f2fd6f358 Merge pull request #9418 from glours/update-v1-install
Update the installation guide for the python version of Compose
2022-04-26 17:45:19 +02:00
Guillaume Lours
b750e5bb4c Update the installation guide for the python version of Compose
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-04-26 17:44:45 +02:00
Ulysses Souza
6eb51d3b5b Merge pull request #8644 from yariksheptykin/patch-1
Explain `--filter` in `ps`
2021-10-15 06:44:19 +02:00
Nicolas De Loof
f35db7f31b document End of Life policy
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-22 09:00:40 +02:00
Iaroslav Sheptykin
cd97ac0fc1 Explain --filter in ps
Explain `--filter` option of compse `ps` in more detail.

Signed-off-by: Iaroslav Sheptykin <i.sheptykin@neusta.de>
2021-09-20 21:35:05 +02:00
Nicolas De Loof
2011bc3cea exclude .github from pre-commit
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-09 15:43:15 +02:00
Nicolas De Loof
7c82d8ad2c only run CI workflow when PR target is branch v2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-09 10:49:39 +02:00
Nicolas De Loof
d06e15323a add official logo as vector graphic
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-06 08:59:59 +02:00
Nicolas De Loof
fa7a7e2cb5 setup compose v2 release workflow
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-02 13:14:42 +02:00
Nicolas De Loof
3e797d6544 setup CI for compose v2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-02 09:01:31 +02:00
Nicolas De Loof
60856228ea document Compose v2 coming soon
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-01 16:28:11 +02:00
Ulysses Souza
4a51af09d6 Merge pull request #8301 from docker/dependabot/add-v2-config-file
Upgrade to GitHub-native Dependabot
2021-06-18 13:29:41 -03:00
Ulysses Souza
318181b21e Merge pull request #7718 from docker/dependabot/pip/paramiko-2.7.2
Bump paramiko from 2.7.1 to 2.7.2
2021-06-15 18:45:33 -03:00
Ulysses Souza
4d5aab95d1 Merge pull request #7728 from docker/dependabot/pip/texttable-1.6.3
Bump texttable from 1.6.2 to 1.6.3
2021-06-15 15:41:50 -03:00
dependabot-preview[bot]
53237b9f9c Bump texttable from 1.6.2 to 1.6.3
Bumps [texttable](https://github.com/foutaise/texttable) from 1.6.2 to 1.6.3.
- [Release notes](https://github.com/foutaise/texttable/releases)
- [Changelog](https://github.com/foutaise/texttable/blob/master/CHANGELOG.md)
- [Commits](https://github.com/foutaise/texttable/compare/v1.6.2...v1.6.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-15 17:27:15 +00:00
Ulysses Souza
2a485a02de Merge pull request #8008 from docker/dependabot/pip/requests-2.25.1
Bump requests from 2.24.0 to 2.25.1
2021-06-15 14:26:09 -03:00
dependabot-preview[bot]
e815126c68 Bump paramiko from 2.7.1 to 2.7.2
Bumps [paramiko](https://github.com/paramiko/paramiko) from 2.7.1 to 2.7.2.
- [Release notes](https://github.com/paramiko/paramiko/releases)
- [Changelog](https://github.com/paramiko/paramiko/blob/master/NEWS)
- [Commits](https://github.com/paramiko/paramiko/compare/2.7.1...2.7.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-15 16:58:29 +00:00
dependabot-preview[bot]
872e7025a0 Bump requests from 2.24.0 to 2.25.1
Bumps [requests](https://github.com/psf/requests) from 2.24.0 to 2.25.1.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/master/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.24.0...v2.25.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-15 16:57:42 +00:00
Ulysses Souza
e6db77b073 Merge pull request #8356 from docker/dependabot/pip/pywin32-301
Bump pywin32 from 227 to 301
2021-06-15 13:57:09 -03:00
Ulysses Souza
cc97ce94b5 Merge pull request #8357 from docker/dependabot/pip/certifi-2021.5.30
Bump certifi from 2020.6.20 to 2021.5.30
2021-06-15 13:56:50 -03:00
Ulysses Souza
addfb6c2b2 Merge pull request #8381 from docker/dependabot/pip/websocket-client-1.1.0
Bump websocket-client from 0.57.0 to 1.1.0
2021-06-15 13:56:28 -03:00
Nicolas De Loof
ce8e6d0a5f warning about wrong repo being used to report issues
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-06-15 17:46:25 +02:00
dependabot-preview[bot]
e5358f273b Bump certifi from 2020.6.20 to 2021.5.30
Bumps [certifi](https://github.com/certifi/python-certifi) from 2020.6.20 to 2021.5.30.
- [Release notes](https://github.com/certifi/python-certifi/releases)
- [Commits](https://github.com/certifi/python-certifi/compare/2020.06.20...2021.05.30)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-15 15:20:45 +00:00
dependabot-preview[bot]
a091f468d6 Bump pywin32 from 227 to 301
Bumps [pywin32](https://github.com/mhammond/pywin32) from 227 to 301.
- [Release notes](https://github.com/mhammond/pywin32/releases)
- [Changelog](https://github.com/mhammond/pywin32/blob/master/CHANGES.txt)
- [Commits](https://github.com/mhammond/pywin32/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-15 15:19:51 +00:00
dependabot-preview[bot]
acb91db8a6 Bump websocket-client from 0.57.0 to 1.1.0
Bumps [websocket-client](https://github.com/websocket-client/websocket-client) from 0.57.0 to 1.1.0.
- [Release notes](https://github.com/websocket-client/websocket-client/releases)
- [Changelog](https://github.com/websocket-client/websocket-client/blob/master/ChangeLog)
- [Commits](https://github.com/websocket-client/websocket-client/compare/v0.57.0...v1.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-06-15 15:19:49 +00:00
Ulysses Souza
dfe472118d Merge pull request #8318 from docker/dependabot/pip/pytest-6.2.4
Bump pytest from 6.0.1 to 6.2.4
2021-06-15 12:19:31 -03:00
Ulysses Souza
947953143c Merge pull request #7983 from docker/dependabot/pip/colorama-0.4.4
Bump colorama from 0.4.3 to 0.4.4
2021-06-15 12:19:18 -03:00
Ulysses Souza
2791d31cfb Merge pull request #8273 from docker/dependabot/pip/ddt-1.4.2
Bump ddt from 1.4.1 to 1.4.2
2021-06-15 12:18:53 -03:00
Ulysses Souza
a99377720c Merge pull request #8358 from docker/dependabot/pip/urllib3-1.26.5
Bump urllib3 from 1.25.10 to 1.26.5
2021-06-15 12:18:26 -03:00
dependabot-preview[bot]
b8f292bbed Bump urllib3 from 1.25.10 to 1.26.5
Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.25.10 to 1.26.5.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](https://github.com/urllib3/urllib3/compare/1.25.10...1.26.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-31 21:26:25 +00:00
Ulysses Souza
73f8cf9132 Merge pull request #8317 from ulyssessouza/post-release-1.29.2
Post release 1.29.2
2021-05-11 17:54:04 -03:00
dependabot-preview[bot]
53add5f372 Bump pytest from 6.0.1 to 6.2.4
Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.0.1 to 6.2.4.
- [Release notes](https://github.com/pytest-dev/pytest/releases)
- [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pytest-dev/pytest/compare/6.0.1...6.2.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-05-10 21:17:06 +00:00
Ulysses Souza
203576363e Remove section mentioning _config_authoring on docs
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-05-10 17:26:17 -03:00
Ulysses Souza
0eaf57466d Update changelog to 1.29.2
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-05-10 17:25:50 -03:00
Ulysses Souza
96a8e3b3c5 Merge pull request #8316 from ulyssessouza/bump-py
Bump py to 1.10.0
2021-05-10 07:09:21 -03:00
Ulysses Souza
aca6edd631 Merge pull request #8313 from ulyssessouza/remove-compose-v2-msg
Remove advertisement for `docker compose` from up
2021-05-10 06:55:42 -03:00
Ulysses Souza
39ab3aee50 Bump py to 1.10.0
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-05-10 06:44:49 -03:00
Ulysses Souza
39c2d42a0e Remove advertisement for docker compose from up
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-05-07 01:41:47 -03:00
dependabot-preview[bot]
397ca0764c Upgrade to GitHub-native Dependabot 2021-04-28 16:46:16 +00:00
Ulysses Souza
aa45dedb3d Merge pull request #8288 from aiordache/release_1.29.1
1.29.1 Post-release updates
2021-04-15 11:41:14 -03:00
Anca Iordache
afb36f236b 1.29.1 Post-release updates
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-15 15:07:50 +02:00
Ulysses Souza
f01e535cf4 Merge pull request #8290 from aiordache/flaky_tests
Update flaky tests on inter-service dependencies
2021-04-15 10:04:06 -03:00
Ulysses Souza
853efbfb54 Merge pull request #8281 from aiordache/Jenkins_update
Update node spec in Jenkinsfile and Docker config mount
2021-04-15 10:03:45 -03:00
Anca Iordache
6ea24001fa mkdir .docker directory before copying the config
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-15 14:16:05 +02:00
Anca Iordache
c3d8e558a2 update path
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-15 13:58:58 +02:00
Anca Iordache
8f9f1111f3 Copy the .docker/config to dind container for authentication
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-15 12:23:17 +02:00
Anca Iordache
1b42ecba14 Update flaky tests on inter-service dependencies
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-15 10:44:32 +02:00
Anca Iordache
adae403b27 Merge pull request #8261 from ulyssessouza/metrics-nosuchcommand
Ignore command names on NoSuchCommand exceptions
2021-04-13 19:38:15 +02:00
Ulysses Souza
0bea52b18d Merge pull request #8280 from aiordache/ipc_recreate
Add IPC mode to the config hash
2021-04-13 14:19:32 -03:00
Ulysses Souza
2d0c9366ff Merge pull request #8279 from aiordache/max_replicas
Add placement.max_replicas_per_node to conversion map
2021-04-13 14:18:42 -03:00
Anca Iordache
8a6dc88f9e Merge pull request #8278 from ulyssessouza/revert-scan-msg
Revert "Add Snyk scan suggestion when building"
2021-04-13 18:52:10 +02:00
Anca Iordache
d79745a2cd hardcode path to docker config
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-13 18:10:59 +02:00
Anca Iordache
1250bb7481 Update node spec in Jenkinsfile
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-13 17:11:29 +02:00
Anca Iordache
3ba41b98d3 Add Ipc mode to the config hash
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-13 16:47:42 +02:00
Anca Iordache
7f7370b811 Add placement.max_replicas_per_node to conversion map
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-04-13 15:55:22 +02:00
Ulysses Souza
a9e8ae190f Revert "Add Snyk scan suggestion when building"
This reverts commit e496c64127.

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-04-13 10:34:06 -03:00
dependabot-preview[bot]
2c6f4b7028 Bump ddt from 1.4.1 to 1.4.2
Bumps [ddt](https://github.com/datadriventests/ddt) from 1.4.1 to 1.4.2.
- [Release notes](https://github.com/datadriventests/ddt/releases)
- [Commits](https://github.com/datadriventests/ddt/compare/1.4.1...1.4.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-12 21:21:44 +00:00
Nicolas De Loof
3eee3e093a change builder API to return imageID
this allows more flexibility running CLI builder, especially we don't
have anymore to parse build output to get build status/imageID and can
pass the console FDs to buildkit

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-04-09 19:29:25 +02:00
Anca Iordache
ad770b272c Merge pull request #8258 from ulyssessouza/bump-1.29.0
Bump 1.29.0
2021-04-09 14:21:03 +01:00
Ulysses Souza
e5cab3ced5 Ignore command names on NoSuchCommand exceptions
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-04-07 20:20:14 -03:00
Ulysses Souza
7984767db2 Bump 1.29.0
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-04-06 18:41:34 -03:00
Anca Iordache
c81046aac0 Merge pull request #8239 from timoxley/patch-1
Mention `--ansi never` in `--no-ansi` deprecation
2021-04-06 19:04:25 +01:00
Tim Kevin Oxley
84c816e887 Mention --ansi never in --no-ansi deprecation
Ideally deprecation messages should point users directly at the non-deprecated alternative so it's a no-brainer for someone to switch to it.

Signed-off-by: Tim Kevin Oxley <secoif@gmail.com>
2021-04-06 14:59:34 -03:00
dependabot-preview[bot]
5b6c3e8389 Bump colorama from 0.4.3 to 0.4.4
Bumps [colorama](https://github.com/tartley/colorama) from 0.4.3 to 0.4.4.
- [Release notes](https://github.com/tartley/colorama/releases)
- [Changelog](https://github.com/tartley/colorama/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/tartley/colorama/compare/0.4.3...0.4.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-06 17:49:36 +00:00
Anca Iordache
1607674374 Merge pull request #8256 from ulyssessouza/bump-py-5
Bump docker-py to 5.0.0 and PyYAML to 5.4.1
2021-04-06 18:48:20 +01:00
Anca Iordache
683fac0dbf Merge pull request #8122 from ojab/add_init_containers
Add init container support
2021-04-06 18:25:24 +01:00
Ulysses Souza
ddee2958ec Bump docker-py to 5.0.0 and PyYAML to 5.4.1
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-04-06 14:24:48 -03:00
Anca Iordache
1ab1cd202b Merge pull request #8091 from docker/dependabot/pip/packaging-20.9
Bump packaging from 20.4 to 20.9
2021-04-06 18:18:25 +01:00
Anca Iordache
1752927dcd Merge pull request #8183 from docker/dependabot/pip/coverage-5.5
Bump coverage from 5.2.1 to 5.5
2021-04-06 18:13:21 +01:00
Anca Iordache
c2ddd71e5f Merge pull request #8232 from aiordache/release_1.28.6
Update changelog for 1.28.6
2021-04-06 18:11:52 +01:00
Anca Iordache
72bbd9c3a6 Merge pull request #8253 from docker/dependabot/pip/python-dotenv-0.17.0
Bump python-dotenv from 0.14.0 to 0.17.0
2021-04-06 18:10:04 +01:00
Anca Iordache
3c9ee678e7 Merge pull request #8247 from ulyssessouza/scan-suggestion
Add Snyk scan suggestion when building
2021-04-06 10:09:07 +01:00
dependabot-preview[bot]
92fefbc9cc Bump python-dotenv from 0.14.0 to 0.17.0
Bumps [python-dotenv](https://github.com/theskumar/python-dotenv) from 0.14.0 to 0.17.0.
- [Release notes](https://github.com/theskumar/python-dotenv/releases)
- [Changelog](https://github.com/theskumar/python-dotenv/blob/master/CHANGELOG.md)
- [Commits](https://github.com/theskumar/python-dotenv/compare/v0.14.0...v0.17.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-04-05 21:23:08 +00:00
Ulysses Souza
e496c64127 Add Snyk scan suggestion when building
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-04-05 12:34:45 -03:00
Chris Crone
84afa518e8 Merge pull request #8061 from albers/completion-profiles
Add bash completion for profiles and a command to list profiles
2021-03-30 09:33:50 +02:00
Anca Iordache
0f6a55e036 Update changelog for 1.28.6
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-03-23 15:18:15 +01:00
Anca Iordache
8ce5e235e4 Add back storage_opts as service property
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-03-23 11:02:51 +01:00
Anca Iordache
c1dddbe608 Merge pull request #8213 from ulyssessouza/fix-exec-error-msg
Fix on removing error message on 'exec' error
2021-03-19 09:45:34 +01:00
Anca Iordache
981b0cd641 Merge pull request #8178 from mgorny/cached-prop-dep
Use built-in functools.cached_property when possible
2021-03-18 20:17:49 +01:00
Ulysses Souza
5ec8af582c Fix on removing error message on 'exec' error
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-03-17 17:49:15 -03:00
Anca Iordache
f5342b600c Add compose.yaml/.yml to default filenames
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-03-16 18:04:51 +01:00
Anca Iordache
4a26d95de4 Make --env-file paths relative to current working directory
Look up compose files in project dir as fallback to no compose file in current working directory
Update config and env-file tests
 - get_default_config does not raise error anymore, returns None if no compose file is found

Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-03-16 18:04:51 +01:00
Ulysses Souza
5b7851f55b Merge pull request #8188 from aiordache/build_context
Do not use context as base dir for Dockerfile when context is a git url
2021-03-11 13:01:07 +01:00
Anca Iordache
eaa22df151 Do not use context as base dir for Dockerfile when context is a git url
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-03-09 19:21:08 +01:00
Ulysses Souza
551f680751 Merge pull request #8187 from aiordache/build_opts
Fix build.extra_hosts list format
2021-03-09 19:20:51 +01:00
Anca Iordache
3e071ec8d9 Fix build.extra_hosts list format
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2021-03-09 18:30:47 +01:00
dependabot-preview[bot]
858ff26731 Bump coverage from 5.2.1 to 5.5
Bumps [coverage](https://github.com/nedbat/coveragepy) from 5.2.1 to 5.5.
- [Release notes](https://github.com/nedbat/coveragepy/releases)
- [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst)
- [Commits](https://github.com/nedbat/coveragepy/compare/coverage-5.2.1...coverage-5.5)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-03-08 22:20:16 +00:00
Michał Górny
2a7c06a050 Use built-in functools.cached_property when possible
The cached_property decorator is built-in in functools module since
Python 3.8.  Use the external cached_property package only for older
versions of Python.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2021-03-06 18:45:59 +01:00
Ulysses Souza
d0b7bc3110 Merge pull request #8160 from aiordache/changelog_1.28.5
Update changelog for 1.28.5
2021-03-02 14:14:56 -03:00
Anca Iordache
fe4f16e448 Merge pull request #8166 from ulyssessouza/advertise-space-compose
Advertise `docker compose` for non linux users
2021-03-02 18:05:10 +01:00
Ulysses Souza
1da4301650 Advertise docker compose for non linux users
This adds messages on:
- Root command (only `docker-compose`)
- Command not found
- `help` command

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-03-02 11:14:07 -03:00
aiordache
c594cb3fc3 Update changelog post-release 1.28.5
Signed-off-by: aiordache <anca.iordache@docker.com>
2021-02-26 10:38:59 +01:00
Slava Kardakov
4daad056c4 Add init container support
Fixes #6855

See https://github.com/compose-spec/compose-spec/pull/134

Signed-off-by: Slava Kardakov <ojab@ojab.ru>
2021-02-18 17:47:59 +00:00
dependabot-preview[bot]
6209baccf3 Bump packaging from 20.4 to 20.9
Bumps [packaging](https://github.com/pypa/packaging) from 20.4 to 20.9.
- [Release notes](https://github.com/pypa/packaging/releases)
- [Changelog](https://github.com/pypa/packaging/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/pypa/packaging/compare/20.4...20.9)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2021-02-01 22:22:56 +00:00
Harald Albers
4e382b9c28 Add bash completion for --profile
Signed-off-by: Harald Albers <github@albersweb.de>
2021-01-22 19:24:15 +00:00
Harald Albers
862107a32a Add option for listing service profiles
For command completion of `docker-compose --profile`, we need a portable
way to get a list of profiles used in the current config.

This commit adds a new option `docker-compose config --profiles`.

Signed-off-by: Harald Albers <github@albersweb.de>
2021-01-22 19:24:15 +00:00
47 changed files with 6902 additions and 167 deletions

View File

@@ -7,6 +7,16 @@ assignees: ''
---
<!--
**DEPRECATION NOTICE:**
Compose V1 is end-of-life, and as such only issues relating to security vulnerabilities will be considered.
Please do not submit issues regarding bugs or improvements.
For a more up-to-date compose, check v2: https://github.com/docker/compose/tree/v2/
-->
<!--
Welcome to the docker-compose issue tracker! Before creating an issue, please heed the following:
@@ -25,7 +35,10 @@ Welcome to the docker-compose issue tracker! Before creating an issue, please he
## Context information (for bug reports)
**Output of `docker-compose version`**
- [ ] Using Compose V2 `docker compose ...`
- [ ] Using Compose V1 `docker-compose ...`
**Output of `docker(-)compose version`**
```
(paste here)
```

View File

@@ -7,6 +7,16 @@ assignees: ''
---
<!--
**DEPRECATION NOTICE:**
Compose V1 is end-of-life, and as such only issues relating to security vulnerabilities will be considered.
Please do not submit issues regarding bugs or improvements.
For a more up-to-date compose, check v2: https://github.com/docker/compose/tree/v2/
-->
<!--
Welcome to the docker-compose issue tracker! Before creating an issue, please heed the following:
@@ -19,6 +29,9 @@ Welcome to the docker-compose issue tracker! Before creating an issue, please he
the original discussion.
-->
/!\ If your request is about evolving the compose file format, please report on the [Compose Specification](https://github.com/compose-spec/compose-spec)
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

View File

@@ -7,6 +7,16 @@ assignees: ''
---
<!--
**DEPRECATION NOTICE:**
Compose V1 is end-of-life, and as such only issues relating to security vulnerabilities will be considered.
Please do not submit issues regarding bugs or improvements.
For a more up-to-date compose, check v2: https://github.com/docker/compose/tree/v2/
-->
Please post on our forums: https://forums.docker.com for questions about using `docker-compose`.
Posts that are not a bug report or a feature/enhancement request will not be addressed on this issue tracker.

28
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
time: "14:00"
timezone: America/Los_Angeles
open-pull-requests-limit: 10
ignore:
- dependency-name: python-dotenv
versions:
- 0.15.0
- 0.16.0
- dependency-name: urllib3
versions:
- 1.26.2
- 1.26.3
- dependency-name: coverage
versions:
- 5.3.1
- "5.4"
- dependency-name: packaging
versions:
- "20.8"
- dependency-name: cached-property
versions:
- 1.5.2

58
.github/workflows/artifacts.yml vendored Normal file
View File

@@ -0,0 +1,58 @@
name: Publish Artifacts
on:
issue_comment:
types: [created]
jobs:
publish-artifacts:
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/generate-artifacts')
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
- name: Build cross platform compose-plugin binaries
run: make -f builder.Makefile cross
- name: Upload macos-amd64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-darwin-amd64
path: ${{ github.workspace }}/bin/docker-compose-darwin-amd64
- name: Upload macos-arm64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-darwin-arm64
path: ${{ github.workspace }}/bin/docker-compose-darwin-arm64
- name: Upload linux-amd64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-linux-amd64
path: ${{ github.workspace }}/bin/docker-compose-linux-amd64
- name: Upload windows-amd64 binary
uses: actions/upload-artifact@v2
with:
name: docker-compose-windows-amd64.exe
path: ${{ github.workspace }}/bin/docker-compose-windows-amd64.exe
- name: Update comment
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ github.event.comment.id }}
body: |
This PR can be tested using [binaries](https://github.com/docker/compose-cli/actions/runs/${{ github.run_id }}).
reactions: eyes

104
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,104 @@
name: Continuous integration
on:
push:
branches:
- v2
pull_request:
branches:
- v2
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- name: Validate go-mod is up-to-date and license headers
run: make validate
- name: Run golangci-lint
env:
BUILD_TAGS: e2e
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin/ v1.39.0
make -f builder.Makefile lint
# only on main branch, costs too much for the gain on every PR
validate-cross-build:
name: Validate cross build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
# Ensure we don't discover cross platform build issues at release time.
# Time used to build linux here is gained back in the build for local E2E step
- name: Build packages
run: make -f builder.Makefile cross
build:
name: Build
runs-on: ubuntu-latest
env:
GO111MODULE: "on"
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go
- name: Set up gosum
run: |
go get -u gotest.tools/gotestsum
- name: Setup docker CLI
run: |
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
- name: Test
env:
BUILD_TAGS: kube
run: make -f builder.Makefile test
- name: Build for local E2E
env:
BUILD_TAGS: e2e
run: make -f builder.Makefile compose-plugin
- name: E2E Test
run: make e2e-compose

11
.github/workflows/pr-closed.yml vendored Normal file
View File

@@ -0,0 +1,11 @@
name: PR cleanup
on:
pull_request:
types: [closed]
jobs:
delete_pr_artifacts:
runs-on: ubuntu-latest
steps:
- uses: stefanluptak/delete-old-pr-artifacts@v1
with:
workflow_filename: ci.yaml

19
.github/workflows/rebase.yml vendored Normal file
View File

@@ -0,0 +1,19 @@
name: Automatic Rebase
on:
issue_comment:
types: [created]
jobs:
rebase:
name: Rebase
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/rebase')
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

49
.github/workflows/release.yaml vendored Normal file
View File

@@ -0,0 +1,49 @@
name: Releaser
on:
workflow_dispatch:
inputs:
tag:
description: 'Release Tag'
required: true
dry-run:
description: 'Dry run'
required: false
default: 'true'
jobs:
upload-release:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go
- name: Setup docker CLI
run: |
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.3.tgz | tar xz
sudo cp ./docker/docker /usr/bin/ && rm -rf docker && docker version
- name: Checkout code into the Go module directory
uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build
run: make -f builder.Makefile cross-compose-plugin
- name: License
run: cp packaging/* bin/
- uses: ncipollo/release-action@v1
with:
artifacts: "bin/*"
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -1,26 +1,28 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 'v0.9.1'
hooks:
- id: check-added-large-files
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-json
- id: debug-statements
- id: end-of-file-fixer
- id: flake8
- id: name-tests-test
exclude: 'tests/(integration/testcases\.py|helpers\.py)'
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: git://github.com/asottile/reorder_python_imports
sha: v1.3.4
hooks:
- id: reorder-python-imports
language_version: 'python3.7'
args:
- --py3-plus
- repo: https://github.com/asottile/pyupgrade
exclude: .github/
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 'v0.9.1'
hooks:
- id: check-added-large-files
- id: check-docstring-first
- id: check-merge-conflict
- id: check-yaml
- id: check-json
- id: debug-statements
- id: end-of-file-fixer
- id: flake8
- id: name-tests-test
exclude: 'tests/(integration/testcases\.py|helpers\.py)'
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: git://github.com/asottile/reorder_python_imports
sha: v1.3.4
hooks:
- id: reorder-python-imports
language_version: 'python3.7'
args:
- --py3-plus
- repo: https://github.com/asottile/pyupgrade
rev: v2.1.0
hooks:
- id: pyupgrade

View File

@@ -1,6 +1,74 @@
Change log
==========
1.29.2 (2021-05-10)
-------------------
[List of PRs / issues for this release](https://github.com/docker/compose/milestone/59?closed=1)
### Miscellaneous
- Remove prompt to use `docker compose` in the `up` command
- Bump `py` to `1.10.0` in `requirements-indirect.txt`
1.29.1 (2021-04-13)
-------------------
[List of PRs / issues for this release](https://github.com/docker/compose/milestone/58?closed=1)
### Bugs
- Fix for invalid handler warning on Windows builds
- Fix config hash to trigger container recreation on IPC mode updates
- Fix conversion map for `placement.max_replicas_per_node`
- Remove extra scan suggestion on build
1.29.0 (2021-04-06)
-------------------
[List of PRs / issues for this release](https://github.com/docker/compose/milestone/56?closed=1)
### Features
- Add profile filter to `docker-compose config`
- Add a `depends_on` condition to wait for successful service completion
### Miscellaneous
- Add image scan message on build
- Update warning message for `--no-ansi` to mention `--ansi never` as alternative
- Bump docker-py to 5.0.0
- Bump PyYAML to 5.4.1
- Bump python-dotenv to 0.17.0
1.28.6 (2021-03-23)
-------------------
[List of PRs / issues for this release](https://github.com/docker/compose/milestone/57?closed=1)
### Bugs
- Make `--env-file` relative to the current working directory and error out for invalid paths. Environment file paths set with `--env-file` are relative to the current working directory while the default `.env` file is located in the project directory which by default is the base directory of the Compose file.
- Fix missing service property `storage_opt` by updating the compose schema
- Fix build `extra_hosts` list format
- Remove extra error message on `exec`
### Miscellaneous
- Add `compose.yml` and `compose.yaml` to default filename list
1.28.5 (2021-02-25)
-------------------
@@ -129,10 +197,7 @@ Change log
- Updates of READMEs
<<<<<<< HEAD
=======
>>>>>>> master
1.27.4 (2020-09-24)
-------------------

136
INSTALL.md Normal file
View File

@@ -0,0 +1,136 @@
# Install Docker Compose
This page contains information on how to install Docker Compose. You can run Compose on macOS, Windows, and 64-bit Linux.
> ⚠️ The installation instructions on this page will help you to install Compose v1 which is a deprecated version. We recommend that you use the [latest version of Docker Compose](https://docs.docker.com/compose/install/).
## Prerequisites
Docker Compose relies on Docker Engine for any meaningful work, so make sure you
have Docker Engine installed either locally or remote, depending on your setup.
- Install
[Docker Engine](https://docs.docker.com/engine/install/#server)
for your OS and then come back here for
instructions on installing the Python version of Compose.
- To run Compose as a non-root user, see [Manage Docker as a non-root user](https://docs.docker.com/engine/install/linux-postinstall/).
## Install Compose
Follow the instructions below to install Compose using the `pip`
Python package manager or to install Compose as a container.
> Install a different version
>
> The instructions below outline installation of the current stable release
> (**v1.29.2**) of Compose. To install a different version of
> Compose, replace the given release number with the one that you want. For instructions to install Compose 2.x.x on Linux, see [Install Compose 2.x.x on Linux](https://docs.docker.com/compose/install/#install-compose-on-linux-systems).
>
> Compose releases are also listed and available for direct download on the
> [Compose repository release page on GitHub](https://github.com/docker/compose/releases).
> To install a **pre-release** of Compose, refer to the [install pre-release builds](#install-pre-release-builds)
> section.
- [Install using pip](#install-using-pip)
- [Install as a container](#install-as-a-container)
#### Install using pip
> For `alpine`, the following dependency packages are needed:
> `py-pip`, `python3-dev`, `libffi-dev`, `openssl-dev`, `gcc`, `libc-dev`, `rust`, `cargo`, and `make`.
{: .important}
You can install Compose from
[pypi](https://pypi.python.org/pypi/docker-compose) using `pip`. If you install
using `pip`, we recommend that you use a
[virtualenv](https://virtualenv.pypa.io/en/latest/) because many operating
systems have python system packages that conflict with docker-compose
dependencies. See the [virtualenv
tutorial](https://docs.python-guide.org/dev/virtualenvs/) to get
started.
```console
$ pip3 install docker-compose
```
If you are not using virtualenv,
```console
$ sudo pip install docker-compose
```
> pip version 6.0 or greater is required.
#### Install as a container
You can also run Compose inside a container, from a small bash script wrapper. To
install Compose as a container run this command:
```console
$ sudo curl -L --fail https://github.com/docker/compose/releases/download/1.29.2/run.sh -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
```
### Install pre-release builds
If you're interested in trying out a pre-release build, you can download release
candidates from the [Compose repository release page on GitHub](https://github.com/docker/compose/releases).
Follow the instructions from the link, which involves running the `curl` command
in your terminal to download the binaries.
Pre-releases built from the "master" branch are also available for download at
[https://dl.bintray.com/docker-compose/master/](https://dl.bintray.com/docker-compose/master/).
> Pre-release builds allow you to try out new features before they are released,
> but may be less stable.
----
## Upgrading
If you're upgrading from Compose 1.2 or earlier, remove or
migrate your existing containers after upgrading Compose. This is because, as of
version 1.3, Compose uses Docker labels to keep track of containers, and your
containers need to be recreated to add the labels.
If Compose detects containers that were created without labels, it refuses
to run, so that you don't end up with two sets of them. If you want to keep using
your existing containers (for example, because they have data volumes you want
to preserve), you can use Compose 1.5.x to migrate them with the following
command:
```console
$ docker-compose migrate-to-labels
```
Alternatively, if you're not worried about keeping them, you can remove them.
Compose just creates new ones.
```console
$ docker container rm -f -v myapp_web_1 myapp_db_1 ...
```
## Uninstall
To uninstall Docker Compose if you installed using `curl`:
```console
$ sudo rm /usr/local/bin/docker-compose
```
To uninstall Docker Compose if you installed using `pip`:
```console
$ pip uninstall docker-compose
```
> Got a "Permission denied" error?
>
> If you get a "Permission denied" error using either of the above
> methods, you probably do not have the proper permissions to remove
> `docker-compose`. To force the removal, prepend `sudo` to either of the above
> commands and run again.

2
Jenkinsfile vendored
View File

@@ -87,7 +87,7 @@ def buildImage(baseImage) {
def runTests(dockerVersion, pythonVersion, baseImage) {
return {
stage("python=${pythonVersion} docker=${dockerVersion} ${baseImage}") {
node("ubuntu && amd64 && !zfs") {
node("ubuntu-2004 && amd64 && !zfs && cgroup1") {
def scmvar = checkout(scm)
def imageName = "dockerpinata/compose:${baseImage}-${scmvar.GIT_COMMIT}"
def storageDriver = sh(script: "docker info -f \'{{.Driver}}\'", returnStdout: true).trim()

View File

@@ -4,6 +4,40 @@ Docker Compose
![Docker Compose](logo.png?raw=true "Docker Compose Logo")
# :warning: *Compose V1 is DEPRECATED* :warning:
Since [Compose V2 is now GA](https://www.docker.com/blog/announcing-compose-v2-general-availability/), Compose V1 is officially **End of Life**. This means that:
- Active development and new features will only be added to the V2 codebase
- Only security-related issues will be considered for V1
Check out the [V2 branch here](https://github.com/docker/compose/tree/v2/)!!
---------------------------------------------
** Compose V2 is **Generally Available**! :star_struck: **
---------------------------------------------
Check it out [here](https://github.com/docker/compose/tree/v2/)!
Read more on the [GA announcement here](https://www.docker.com/blog/announcing-compose-v2-general-availability/)
---------------------------------------------
V1 vs V2 transition :hourglass_flowing_sand:
--------------------------------------------
"Generally Available" will mean:
- New features and bug fixes will only be considered in the V2 codebase
- Users on Mac/Windows will be defaulted into Docker Compose V2, but can still opt out through the UI and the CLI. This means when running `docker-compose` you will actually be running `docker compose`
- Our current goal is for users on Linux to receive Compose v2 with the latest version of the docker CLI, but is pending some technical discussion. Users will be able to use [compose switch](https://github.com/docker/compose-switch) to enable redirection of `docker-compose` to `docker compose`
- Docker Compose V1 will continue to be maintained regarding security issues
- [v2 branch](https://github.com/docker/compose/tree/v2) will become the default one at that time
:lock_with_ink_pen: Depending on the feedback we receive from the community of GA and the adoption on Linux, we will come up with a plan to deprecate v1, but as of right now there is no concrete timeline as we want the transition to be as smooth as possible for all users. It is important to note that we have no plans of removing any aliasing of `docker-compose` to `docker compose`. We want to make it as easy as possible to switch and not break any ones scripts. We will follow up with a blog post in the next few months with more information of an exact timeline of V1 being marked as deprecated and end of support for security issues. Wed love to hear your feedback! You can provide it [here](https://github.com/docker/roadmap/issues/257).
About
-----
Docker Compose is a tool for running multi-container applications on Docker
defined using the [Compose file format](https://compose-spec.io).
A Compose file is used to define how the one or more containers that make up
@@ -21,26 +55,10 @@ the Docker CLI. You can read more about how to do this:
Where to get Docker Compose
----------------------------
### Windows and macOS
All the instructions to install the Python version of Docker Compose, aka `v1`,
are described in the [installation guide](./INSTALL.md).
Docker Compose is included in
[Docker Desktop](https://www.docker.com/products/docker-desktop)
for Windows and macOS.
### Linux
You can download Docker Compose binaries from the
[release page](https://github.com/docker/compose/releases) on this repository.
### Using pip
If your platform is not supported, you can download Docker Compose using `pip`:
```console
pip install docker-compose
```
> **Note:** Docker Compose requires Python 3.6 or later.
> ⚠️ This version is a deprecated version of Compose. We recommend that you use the [latest version of Docker Compose](https://docs.docker.com/compose/install/).
Quick Start
-----------

View File

@@ -1 +1 @@
__version__ = '1.28.5'
__version__ = '1.30.0dev'

View File

@@ -23,6 +23,7 @@ from ..config import resolve_build_args
from ..config.environment import Environment
from ..config.serialize import serialize_config
from ..config.types import VolumeSpec
from ..const import IS_LINUX_PLATFORM
from ..const import IS_WINDOWS_PLATFORM
from ..errors import StreamParseError
from ..metrics.decorator import metrics
@@ -78,8 +79,10 @@ def main(): # noqa: C901
try:
command_func = dispatch()
command_func()
if not IS_LINUX_PLATFORM and command == 'help':
print("\nDocker Compose is now in the Docker CLI, try `docker compose` help")
except (KeyboardInterrupt, signals.ShutdownException):
exit_with_metrics(command, "Aborting.", status=Status.FAILURE)
exit_with_metrics(command, "Aborting.", status=Status.CANCELED)
except (UserError, NoSuchService, ConfigurationError,
ProjectError, OperationFailedError) as e:
exit_with_metrics(command, e.msg, status=Status.FAILURE)
@@ -98,7 +101,10 @@ def main(): # noqa: C901
e.service.name), status=Status.FAILURE)
except NoSuchCommand as e:
commands = "\n".join(parse_doc_section("commands:", getdoc(e.supercommand)))
exit_with_metrics(e.command, "No such command: {}\n\n{}".format(e.command, commands))
if not IS_LINUX_PLATFORM:
commands += "\n\nDocker Compose is now in the Docker CLI, try `docker compose`"
exit_with_metrics("", log_msg="No such command: {}\n\n{}".format(
e.command, commands), status=Status.FAILURE)
except (errors.ConnectionError, StreamParseError):
exit_with_metrics(command, status=Status.FAILURE)
except SystemExit as e:
@@ -116,6 +122,10 @@ def main(): # noqa: C901
code = 0
if isinstance(e.code, int):
code = e.code
if not IS_LINUX_PLATFORM and not command:
msg += "\n\nDocker Compose is now in the Docker CLI, try `docker compose`"
exit_with_metrics(command, log_msg=msg, status=status,
exit_code=code)
@@ -128,7 +138,7 @@ def get_filtered_args(args):
def exit_with_metrics(command, log_msg=None, status=Status.SUCCESS, exit_code=1):
if log_msg:
if log_msg and command != 'exec':
if not exit_code:
log.info(log_msg)
else:
@@ -162,7 +172,8 @@ def dispatch():
if options.get("--no-ansi"):
if options.get("--ansi"):
raise UserError("--no-ansi and --ansi cannot be combined.")
log.warning('--no-ansi option is deprecated and will be removed in future versions.')
log.warning('--no-ansi option is deprecated and will be removed in future versions. '
'Use `--ansi never` instead.')
ansi_mode = AnsiMode.NEVER
setup_console_handler(console_handler,
@@ -381,6 +392,7 @@ class TopLevelCommand:
--no-interpolate Don't interpolate environment variables.
-q, --quiet Only validate the configuration, don't print
anything.
--profiles Print the profile names, one per line.
--services Print the service names, one per line.
--volumes Print the volume names, one per line.
--hash="*" Print the service config hash, one per line.
@@ -400,6 +412,15 @@ class TopLevelCommand:
if options['--quiet']:
return
if options['--profiles']:
profiles = set()
for service in compose_config.services:
if 'profiles' in service:
for profile in service['profiles']:
profiles.add(profile)
print('\n'.join(sorted(profiles)))
return
if options['--services']:
print('\n'.join(service['name'] for service in compose_config.services))
return
@@ -757,7 +778,9 @@ class TopLevelCommand:
Options:
-q, --quiet Only display IDs
--services Display services
--filter KEY=VAL Filter services by a property
--filter KEY=VAL Filter services by a property. KEY is either:
1. `source` with values `image`, or `build`;
2. `status` with values `running`, `stopped`, `paused`, or `restarted`.
-a, --all Show all stopped containers (including those created by the run command)
"""
if options['--quiet'] and options['--services']:

View File

@@ -188,7 +188,7 @@
"properties": {
"condition": {
"type": "string",
"enum": ["service_started", "service_healthy"]
"enum": ["service_started", "service_healthy", "service_completed_successfully"]
}
},
"required": ["condition"]
@@ -335,7 +335,6 @@
"read_only": {"type": "boolean"},
"restart": {"type": "string"},
"runtime": {
"deprecated": true,
"type": "string"
},
"scale": {
@@ -367,6 +366,7 @@
"stdin_open": {"type": "boolean"},
"stop_grace_period": {"type": "string", "format": "duration"},
"stop_signal": {"type": "string"},
"storage_opt": {"type": "object"},
"tmpfs": {"$ref": "#/definitions/string_or_list"},
"tty": {"type": "boolean"},
"ulimits": {

View File

@@ -10,7 +10,11 @@ from operator import attrgetter
from operator import itemgetter
import yaml
from cached_property import cached_property
try:
from functools import cached_property
except ImportError:
from cached_property import cached_property
from . import types
from ..const import COMPOSE_SPEC as VERSION
@@ -149,9 +153,14 @@ DOCKER_VALID_URL_PREFIXES = (
SUPPORTED_FILENAMES = [
'docker-compose.yml',
'docker-compose.yaml',
'compose.yml',
'compose.yaml',
]
DEFAULT_OVERRIDE_FILENAMES = ('docker-compose.override.yml', 'docker-compose.override.yaml')
DEFAULT_OVERRIDE_FILENAMES = ('docker-compose.override.yml',
'docker-compose.override.yaml',
'compose.override.yml',
'compose.override.yaml')
log = logging.getLogger(__name__)
@@ -304,7 +313,16 @@ def find(base_dir, filenames, environment, override_dir=None):
if filenames:
filenames = [os.path.join(base_dir, f) for f in filenames]
else:
# search for compose files in the base dir and its parents
filenames = get_default_config_files(base_dir)
if not filenames and not override_dir:
# none found in base_dir and no override_dir defined
raise ComposeFileNotFound(SUPPORTED_FILENAMES)
if not filenames:
# search for compose files in the project directory and its parents
filenames = get_default_config_files(override_dir)
if not filenames:
raise ComposeFileNotFound(SUPPORTED_FILENAMES)
log.debug("Using configuration files: {}".format(",".join(filenames)))
return ConfigDetails(
@@ -335,7 +353,7 @@ def get_default_config_files(base_dir):
(candidates, path) = find_candidates_in_parent_dirs(SUPPORTED_FILENAMES, base_dir)
if not candidates:
raise ComposeFileNotFound(SUPPORTED_FILENAMES)
return None
winner = candidates[0]
@@ -556,8 +574,7 @@ def process_config_section(config_file, config, section, environment, interpolat
config_file.version,
config,
section,
environment
)
environment)
else:
return config

View File

@@ -54,9 +54,10 @@ class Environment(dict):
if base_dir is None:
return result
if env_file:
env_file_path = os.path.join(base_dir, env_file)
else:
env_file_path = os.path.join(base_dir, '.env')
env_file_path = os.path.join(os.getcwd(), env_file)
return cls(env_vars_from_file(env_file_path))
env_file_path = os.path.join(base_dir, '.env')
try:
return cls(env_vars_from_file(env_file_path))
except EnvFileNotFound:

View File

@@ -243,6 +243,7 @@ class ConversionMap:
service_path('healthcheck', 'disable'): to_boolean,
service_path('deploy', 'labels', PATH_JOKER): to_str,
service_path('deploy', 'replicas'): to_int,
service_path('deploy', 'placement', 'max_replicas_per_node'): to_int,
service_path('deploy', 'resources', 'limits', "cpus"): to_float,
service_path('deploy', 'update_config', 'parallelism'): to_int,
service_path('deploy', 'update_config', 'max_failure_ratio'): to_float,

View File

@@ -5,6 +5,7 @@ from .version import ComposeVersion
DEFAULT_TIMEOUT = 10
HTTP_TIMEOUT = 60
IS_WINDOWS_PLATFORM = (sys.platform == "win32")
IS_LINUX_PLATFORM = (sys.platform == "linux")
LABEL_CONTAINER_NUMBER = 'com.docker.compose.container-number'
LABEL_ONE_OFF = 'com.docker.compose.oneoff'
LABEL_PROJECT = 'com.docker.compose.project'

View File

@@ -27,3 +27,8 @@ class NoHealthCheckConfigured(HealthCheckException):
service_name
)
)
class CompletedUnsuccessfully(Exception):
def __init__(self, container_id, exit_code):
self.msg = 'Container "{}" exited with code {}.'.format(container_id, exit_code)

View File

@@ -36,7 +36,7 @@ class MetricsCommand(requests.Session):
context_type=None, status=Status.SUCCESS,
source=MetricsSource.CLI, uri=None):
super().__init__()
self.command = "compose " + command if command else "compose --help"
self.command = ("compose " + command).strip() if command else "compose --help"
self.context = context_type or ContextAPI.get_current_context().context_type or 'moby'
self.source = source
self.status = status.value

View File

@@ -16,6 +16,7 @@ from compose.cli.colors import green
from compose.cli.colors import red
from compose.cli.signals import ShutdownException
from compose.const import PARALLEL_LIMIT
from compose.errors import CompletedUnsuccessfully
from compose.errors import HealthCheckFailed
from compose.errors import NoHealthCheckConfigured
from compose.errors import OperationFailedError
@@ -61,7 +62,8 @@ def parallel_execute_watch(events, writer, errors, results, msg, get_name, fail_
elif isinstance(exception, APIError):
errors[get_name(obj)] = exception.explanation
writer.write(msg, get_name(obj), 'error', red)
elif isinstance(exception, (OperationFailedError, HealthCheckFailed, NoHealthCheckConfigured)):
elif isinstance(exception, (OperationFailedError, HealthCheckFailed, NoHealthCheckConfigured,
CompletedUnsuccessfully)):
errors[get_name(obj)] = exception.msg
writer.write(msg, get_name(obj), 'error', red)
elif isinstance(exception, UpstreamError):
@@ -241,6 +243,12 @@ def feed_queue(objects, func, get_deps, results, state, limiter):
'not processing'.format(obj)
)
results.put((obj, None, e))
except CompletedUnsuccessfully as e:
log.debug(
'Service(s) upstream of {} did not completed successfully - '
'not processing'.format(obj)
)
results.put((obj, None, e))
if state.is_done():
results.put(STOP)

View File

@@ -1,6 +1,5 @@
import enum
import itertools
import json
import logging
import os
import re
@@ -45,6 +44,7 @@ from .const import LABEL_VERSION
from .const import NANOCPUS_SCALE
from .const import WINDOWS_LONGPATH_PREFIX
from .container import Container
from .errors import CompletedUnsuccessfully
from .errors import HealthCheckFailed
from .errors import NoHealthCheckConfigured
from .errors import OperationFailedError
@@ -112,6 +112,7 @@ HOST_CONFIG_KEYS = [
CONDITION_STARTED = 'service_started'
CONDITION_HEALTHY = 'service_healthy'
CONDITION_COMPLETED_SUCCESSFULLY = 'service_completed_successfully'
class BuildError(Exception):
@@ -712,6 +713,7 @@ class Service:
'image_id': image_id(),
'links': self.get_link_names(),
'net': self.network_mode.id,
'ipc_mode': self.ipc_mode.mode,
'networks': self.networks,
'secrets': self.secrets,
'volumes_from': [
@@ -753,6 +755,8 @@ class Service:
configs[svc] = lambda s: True
elif config['condition'] == CONDITION_HEALTHY:
configs[svc] = lambda s: s.is_healthy()
elif config['condition'] == CONDITION_COMPLETED_SUCCESSFULLY:
configs[svc] = lambda s: s.is_completed_successfully()
else:
# The config schema already prevents this, but it might be
# bypassed if Compose is called programmatically.
@@ -1103,8 +1107,9 @@ class Service:
'Impossible to perform platform-targeted builds for API version < 1.35'
)
builder = self.client if not cli else _CLIBuilder(progress)
build_output = builder.build(
builder = _ClientBuilder(self.client) if not cli else _CLIBuilder(progress)
return builder.build(
service=self,
path=path,
tag=self.image_name,
rm=rm,
@@ -1125,30 +1130,7 @@ class Service:
gzip=gzip,
isolation=build_opts.get('isolation', self.options.get('isolation', None)),
platform=self.platform,
)
try:
all_events = list(stream_output(build_output, output_stream))
except StreamOutputError as e:
raise BuildError(self, str(e))
# Ensure the HTTP connection is not reused for another
# streaming command, as the Docker daemon can sometimes
# complain about it
self.client.close()
image_id = None
for event in all_events:
if 'stream' in event:
match = re.search(r'Successfully built ([0-9a-f]+)', event.get('stream', ''))
if match:
image_id = match.group(1)
if image_id is None:
raise BuildError(self, event if all_events else 'Unknown')
return image_id
output_stream=output_stream)
def get_cache_from(self, build_opts):
cache_from = build_opts.get('cache_from', None)
@@ -1304,6 +1286,21 @@ class Service:
raise HealthCheckFailed(ctnr.short_id)
return result
def is_completed_successfully(self):
""" Check that all containers for this service has completed successfully
Returns false if at least one container does not exited and
raises CompletedUnsuccessfully exception if at least one container
exited with non-zero exit code.
"""
result = True
for ctnr in self.containers(stopped=True):
ctnr.inspect()
if ctnr.get('State.Status') != 'exited':
result = False
elif ctnr.exit_code != 0:
raise CompletedUnsuccessfully(ctnr.short_id, ctnr.exit_code)
return result
def _parse_proxy_config(self):
client = self.client
if 'proxies' not in client._general_configs:
@@ -1790,20 +1787,77 @@ def rewrite_build_path(path):
return path
class _CLIBuilder:
def __init__(self, progress):
self._progress = progress
class _ClientBuilder:
def __init__(self, client):
self.client = client
def build(self, path, tag=None, quiet=False, fileobj=None,
def build(self, service, path, tag=None, quiet=False, fileobj=None,
nocache=False, rm=False, timeout=None,
custom_context=False, encoding=None, pull=False,
forcerm=False, dockerfile=None, container_limits=None,
decode=False, buildargs=None, gzip=False, shmsize=None,
labels=None, cache_from=None, target=None, network_mode=None,
squash=None, extra_hosts=None, platform=None, isolation=None,
use_config_proxy=True):
use_config_proxy=True, output_stream=sys.stdout):
build_output = self.client.build(
path=path,
tag=tag,
nocache=nocache,
rm=rm,
pull=pull,
forcerm=forcerm,
dockerfile=dockerfile,
labels=labels,
cache_from=cache_from,
buildargs=buildargs,
network_mode=network_mode,
target=target,
shmsize=shmsize,
extra_hosts=extra_hosts,
container_limits=container_limits,
gzip=gzip,
isolation=isolation,
platform=platform)
try:
all_events = list(stream_output(build_output, output_stream))
except StreamOutputError as e:
raise BuildError(service, str(e))
# Ensure the HTTP connection is not reused for another
# streaming command, as the Docker daemon can sometimes
# complain about it
self.client.close()
image_id = None
for event in all_events:
if 'stream' in event:
match = re.search(r'Successfully built ([0-9a-f]+)', event.get('stream', ''))
if match:
image_id = match.group(1)
if image_id is None:
raise BuildError(service, event if all_events else 'Unknown')
return image_id
class _CLIBuilder:
def __init__(self, progress):
self._progress = progress
def build(self, service, path, tag=None, quiet=False, fileobj=None,
nocache=False, rm=False, timeout=None,
custom_context=False, encoding=None, pull=False,
forcerm=False, dockerfile=None, container_limits=None,
decode=False, buildargs=None, gzip=False, shmsize=None,
labels=None, cache_from=None, target=None, network_mode=None,
squash=None, extra_hosts=None, platform=None, isolation=None,
use_config_proxy=True, output_stream=sys.stdout):
"""
Args:
service (str): Service to be built
path (str): Path to the directory containing the Dockerfile
buildargs (dict): A dictionary of build arguments
cache_from (:py:class:`list`): A list of images used for build
@@ -1852,10 +1906,11 @@ class _CLIBuilder:
configuration file (``~/.docker/config.json`` by default)
contains a proxy configuration, the corresponding environment
variables will be set in the container being built.
output_stream (writer): stream to use for build logs
Returns:
A generator for the build output.
"""
if dockerfile:
if dockerfile and os.path.isdir(path):
dockerfile = os.path.join(path, dockerfile)
iidfile = tempfile.mktemp()
@@ -1877,38 +1932,25 @@ class _CLIBuilder:
command_builder.add_arg("--isolation", isolation)
if extra_hosts:
for host, ip in extra_hosts.items():
command_builder.add_arg("--add-host", "{}:{}".format(host, ip))
if isinstance(extra_hosts, dict):
extra_hosts = ["{}:{}".format(host, ip) for host, ip in extra_hosts.items()]
for host in extra_hosts:
command_builder.add_arg("--add-host", "{}".format(host))
args = command_builder.build([path])
magic_word = "Successfully built "
appear = False
with subprocess.Popen(args, stdout=subprocess.PIPE,
with subprocess.Popen(args, stdout=output_stream, stderr=sys.stderr,
universal_newlines=True) as p:
while True:
line = p.stdout.readline()
if not line:
break
if line.startswith(magic_word):
appear = True
yield json.dumps({"stream": line})
p.communicate()
if p.returncode != 0:
raise StreamOutputError()
raise BuildError(service, "Build failed")
with open(iidfile) as f:
line = f.readline()
image_id = line.split(":")[1].strip()
os.remove(iidfile)
# In case of `DOCKER_BUILDKIT=1`
# there is no success message already present in the output.
# Since that's the way `Service::build` gets the `image_id`
# it has to be added `manually`
if not appear:
yield json.dumps({"stream": "{}{}\n".format(magic_word, image_id)})
return image_id
class _CommandBuilder:

View File

@@ -138,7 +138,7 @@ _docker_compose_config() {
;;
esac
COMPREPLY=( $( compgen -W "--hash --help --no-interpolate --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
COMPREPLY=( $( compgen -W "--hash --help --no-interpolate --profiles --quiet -q --resolve-image-digests --services --volumes" -- "$cur" ) )
}
@@ -172,6 +172,10 @@ _docker_compose_docker_compose() {
COMPREPLY=( $( compgen -W "debug info warning error critical" -- "$cur" ) )
return
;;
--profile)
COMPREPLY=( $( compgen -W "$(__docker_compose_q config --profiles)" -- "$cur" ) )
return
;;
--project-directory)
_filedir -d
return
@@ -618,10 +622,11 @@ _docker_compose() {
--tlskey
"
# These options are require special treatment when searching the command.
# These options require special treatment when searching the command.
local top_level_options_with_args="
--ansi
--log-level
--profile
"
COMPREPLY=()

View File

@@ -0,0 +1,474 @@
There are three legacy versions of the Compose file format:
- Version 1. This is specified by omitting a `version` key at the root of the YAML.
- Version 2.x. This is specified with a `version: '2'` or `version: '2.1'`, etc., entry at the root of the YAML.
- Version 3.x, designed to be cross-compatible between Compose and the Docker Engine's
[swarm mode](https://docs.docker.com/engine/swarm/). This is specified with a `version: '3'` or `version: '3.1'`, etc., entry at the root of the YAML.
The latest and recommended version of the Compose file format is defined by the [Compose Specification](https://docs.docker.com/compose/compose-file/). This format merges the 2.x and 3.x versions and is implemented by **Compose 1.27.0+**.
> **Note**
>
> If you're using [multiple Compose files](https://docs.docker.com/compose/multiple-compose-files/) or
> [extending services](https://docs.docker.com/compose/multiple-compose-files/extends/),
> each file must be of the same version - you cannot, for example,
> mix version 1 and 2 in a single project.
Several things differ depending on which version you use:
- The structure and permitted configuration keys
- The minimum Docker Engine version you must be running
- Compose's behaviour with regards to networking
These differences are explained below.
### Version 2
Compose files using the version 2 syntax must indicate the version number at
the root of the document. All [services](compose-file-v2.md#service-configuration-reference)
must be declared under the `services` key.
Version 2 files are supported by **Compose 1.6.0+** and require a Docker Engine
of version **1.10.0+**.
Named [volumes](compose-file-v2.md#volume-configuration-reference) can be declared under the
`volumes` key, and [networks](compose-file-v2.md#network-configuration-reference) can be declared
under the `networks` key.
By default, every container joins an application-wide default network, and is
discoverable at a hostname that's the same as the service name. This means
[links](compose-file-v2.md#links) are largely unnecessary. For more details, see
[Networking in Compose](https://docs.docker.com/compose/networking/).
> **Note**
>
> With Compose version 2, when specifying the Compose file version to use, make sure to
> specify both the _major_ and _minor_ numbers. If no minor version is given,
> `0` is used by default and not the latest minor version. As a result, features added in later versions will not be supported. For example:
>
> ```yaml
> version: "2"
> ```
>
> is equivalent to:
>
> ```yaml
> version: "2.0"
> ```
Simple example:
version: "{{% param "compose_file_v2" %}}"
services:
web:
build: .
ports:
- "8000:5000"
volumes:
- .:/code
redis:
image: redis
A more extended example, defining volumes and networks:
version: "{{% param "compose_file_v2" %}}"
services:
web:
build: .
ports:
- "8000:5000"
volumes:
- .:/code
networks:
- front-tier
- back-tier
redis:
image: redis
volumes:
- redis-data:/var/lib/redis
networks:
- back-tier
volumes:
redis-data:
driver: local
networks:
front-tier:
driver: bridge
back-tier:
driver: bridge
Several other options were added to support networking, such as:
* [`aliases`](compose-file-v2.md#aliases)
* The [`depends_on`](compose-file-v2.md#depends_on) option can be used in place of links to indicate dependencies
between services and startup order.
version: "{{% param "compose_file_v2" %}}"
services:
web:
build: .
depends_on:
- db
- redis
redis:
image: redis
db:
image: postgres
* [`ipv4_address`, `ipv6_address`](compose-file-v2.md#ipv4_address-ipv6_address)
[Variable substitution](compose-file-v2.md#variable-substitution) also was added in Version 2.
### Version 2.1
An upgrade of [version 2](#version-2) that introduces new parameters only
available with Docker Engine version **1.12.0+**. Version 2.1 files are
supported by **Compose 1.9.0+**.
Introduces the following additional parameters:
- [`link_local_ips`](compose-file-v2.md#link_local_ips)
- [`isolation`](compose-file-v2.md#isolation-1) in build configurations and
service definitions
- `labels` for [volumes](compose-file-v2.md#volume-configuration-reference),
[networks](compose-file-v2.md#network-configuration-reference), and
[build](compose-file-v3.md#build)
- `name` for [volumes](compose-file-v2.md#volume-configuration-reference)
- [`userns_mode`](compose-file-v2.md#userns_mode)
- [`healthcheck`](compose-file-v2.md#healthcheck)
- [`sysctls`](compose-file-v2.md#sysctls)
- [`pids_limit`](compose-file-v2.md#pids_limit)
- [`oom_kill_disable`](compose-file-v2.md#cpu-and-other-resources)
- [`cpu_period`](compose-file-v2.md#cpu-and-other-resources)
### Version 2.2
An upgrade of [version 2.1](#version-21) that introduces new parameters only
available with Docker Engine version **1.13.0+**. Version 2.2 files are
supported by **Compose 1.13.0+**. This version also allows you to specify
default scale numbers inside the service's configuration.
Introduces the following additional parameters:
- [`init`](compose-file-v2.md#init)
- [`scale`](compose-file-v2.md#scale)
- [`cpu_rt_runtime` and `cpu_rt_period`](compose-file-v2.md#cpu_rt_runtime-cpu_rt_period)
- [`network`](compose-file-v2.md#network) for [build configurations](compose-file-v2.md#build)
### Version 2.3
An upgrade of [version 2.2](#version-22) that introduces new parameters only
available with Docker Engine version **17.06.0+**. Version 2.3 files are
supported by **Compose 1.16.0+**.
Introduces the following additional parameters:
- [`target`](compose-file-v2.md#target), [`extra_hosts`](compose-file-v2.md#extra_hosts-1) and
[`shm_size`](compose-file-v2.md#shm_size) for [build configurations](compose-file-v2.md#build)
- `start_period` for [`healthchecks`](compose-file-v2.md#healthcheck)
- ["Long syntax" for volumes](compose-file-v2.md#long-syntax)
- [`runtime`](compose-file-v2.md#runtime) for service definitions
- [`device_cgroup_rules`](compose-file-v2.md#device_cgroup_rules)
### Version 2.4
An upgrade of [version 2.3](#version-23) that introduces new parameters only
available with Docker Engine version **17.12.0+**. Version 2.4 files are
supported by **Compose 1.21.0+**.
Introduces the following additional parameters:
- [`platform`](compose-file-v2.md#platform) for service definitions
- Support for extension fields at the root of service, network, and volume
definitions
### Version 3
Designed to be cross-compatible between Compose and the Docker Engine's
[swarm mode](/engine/swarm/), version 3 removes several options and adds
several more.
- Removed: `volume_driver`, `volumes_from`, `cpu_shares`, `cpu_quota`,
`cpuset`, `mem_limit`, `memswap_limit`, `extends`, `group_add`. See
the [upgrading](#upgrading) guide for how to migrate away from these.
- Added: [deploy](compose-file-v3.md#deploy)
If only the major version is given (`version: '3'`),
the latest minor version is used by default.
### Version 3.1
An upgrade of [version 3](#version-3) that introduces new parameters only
available with Docker Engine version **1.13.1+**, and higher.
Introduces the following additional parameters:
- [`secrets`](compose-file-v3.md#secrets)
### Version 3.2
An upgrade of [version 3](#version-3) that introduces new parameters only
available with Docker Engine version **17.04.0+**, and higher.
Introduces the following additional parameters:
- [`cache_from`](compose-file-v3.md#cache_from) in [build configurations](compose-file-v3.md#build)
- Long syntax for [ports](compose-file-v3.md#ports) and [volume mounts](compose-file-v3.md#volumes)
- [`attachable`](compose-file-v3.md#attachable) network driver option
- [deploy `endpoint_mode`](compose-file-v3.md#endpoint_mode)
- [deploy placement `preference`](compose-file-v3.md#placement)
### Version 3.3
An upgrade of [version 3](#version-3) that introduces new parameters only
available with Docker Engine version **17.06.0+**, and higher.
Introduces the following additional parameters:
- [build `labels`](compose-file-v3.md#build)
- [`credential_spec`](compose-file-v3.md#credential_spec)
- [`configs`](compose-file-v3.md#configs)
### Version 3.4
An upgrade of [version 3](#version-3) that introduces new parameters. It is
only available with Docker Engine version **17.09.0** and higher.
Introduces the following additional parameters:
- [`target`](compose-file-v3.md#target) and [`network`](compose-file-v3.md#network) in
[build configurations](compose-file-v3.md#build)
- `start_period` for [`healthchecks`](compose-file-v3.md#healthcheck)
- `order` for [update configurations](compose-file-v3.md#update_config)
- `name` for [volumes](compose-file-v3.md#volume-configuration-reference)
### Version 3.5
An upgrade of [version 3](#version-3) that introduces new parameters. It is
only available with Docker Engine version **17.12.0** and higher.
Introduces the following additional parameters:
- [`isolation`](compose-file-v3.md#isolation) in service definitions
- `name` for networks, secrets and configs
- `shm_size` in [build configurations](compose-file-v3.md#build)
### Version 3.6
An upgrade of [version 3](#version-3) that introduces new parameters. It is
only available with Docker Engine version **18.02.0** and higher.
Introduces the following additional parameters:
- [`tmpfs` size](compose-file-v3.md#long-syntax-3) for `tmpfs`-type mounts
### Version 3.7
An upgrade of [version 3](#version-3) that introduces new parameters. It is
only available with Docker Engine version **18.06.0** and higher.
Introduces the following additional parameters:
- [`init`](compose-file-v3.md#init) in service definitions
- [`rollback_config`](compose-file-v3.md#rollback_config) in deploy configurations
- Support for extension fields at the root of service, network, volume, secret
and config definitions
### Version 3.8
An upgrade of [version 3](#version-3) that introduces new parameters. It is
only available with Docker Engine version **19.03.0** and higher.
Introduces the following additional parameters:
- [`max_replicas_per_node`](compose-file-v3.md#max_replicas_per_node) in placement
configurations
- `template_driver` option for [config](compose-file-v3.md#configs-configuration-reference)
and [secret](compose-file-v3.md#secrets-configuration-reference) configurations. This
option is only supported when deploying swarm services using
`docker stack deploy`.
- `driver` and `driver_opts` option for [secret](compose-file-v3.md#secrets-configuration-reference)
configurations. This option is only supported when deploying swarm services
using `docker stack deploy`.
### Version 1 (Deprecated)
Compose versions below 1.6.x are
Compose files that do not declare a version are considered "version 1". In those
files, all the [services](compose-file-v3.md#service-configuration-reference) are
declared at the root of the document.
Version 1 is supported by Compose up to 1.6.x** and has been deprecated.
Version 1 files cannot declare named
[volumes](compose-file-v3.md#volume-configuration-reference), [networks](compose-file-v3.md#network-configuration-reference) or
[build arguments](compose-file-v3.md#args).
Compose does not take advantage of [networking](https://docs.docker.com/compose/networking/) when you
use version 1: every container is placed on the default `bridge` network and is
reachable from every other container at its IP address. You need to use
`links` to enable discovery between containers.
Example:
web:
build: .
ports:
- "8000:5000"
volumes:
- .:/code
links:
- redis
redis:
image: redis
## Upgrading
### Version 2.x to 3.x
Between versions 2.x and 3.x, the structure of the Compose file is the same, but
several options have been removed:
- `volume_driver`: Instead of setting the volume driver on the service, define
a volume using the
[top-level `volumes` option](compose-file-v3.md#volume-configuration-reference)
and specify the driver there.
version: "3.8"
services:
db:
image: postgres
volumes:
- data:/var/lib/postgresql/data
volumes:
data:
driver: mydriver
- `volumes_from`: To share a volume between services, define it using the
[top-level `volumes` option](compose-file-v3.md#volume-configuration-reference)
and reference it from each service that shares it using the
[service-level `volumes` option](compose-file-v3.md#driver).
- `cpu_shares`, `cpu_quota`, `cpuset`, `mem_limit`, `memswap_limit`: These
have been replaced by the [resources](compose-file-v3.md#resources) key under
`deploy`. `deploy` configuration only takes effect when using
`docker stack deploy`, and is ignored by `docker-compose`.
- `extends`: This option has been removed for `version: "3.x"` Compose files.
For more information on `extends`, see
[Extending services](https://docs.docker.com/compose/multiple-compose-files/extends/).
- `group_add`: This option has been removed for `version: "3.x"` Compose files.
- `pids_limit`: This option has not been introduced in `version: "3.x"` Compose files.
- `link_local_ips` in `networks`: This option has not been introduced in
`version: "3.x"` Compose files.
#### Compatibility mode
`docker-compose` 1.20.0 introduces a new `--compatibility` flag designed to
help developers transition to version 3 more easily. When enabled,
`docker-compose` reads the `deploy` section of each service's definition and
attempts to translate it into the equivalent version 2 parameter. Currently,
the following deploy keys are translated:
- [resources](compose-file-v3.md#resources) limits and memory reservations
- [replicas](compose-file-v3.md#replicas)
- [restart_policy](compose-file-v3.md#restart_policy) `condition` and `max_attempts`
All other keys are ignored and produce a warning if present. You can review
the configuration that will be used to deploy by using the `--compatibility`
flag with the `config` command.
> Do not use this in production
>
> We recommend against using `--compatibility` mode in production. The
> resulting configuration is only an approximate using non-Swarm mode
> properties, it may produce unexpected results.
### Version 1 to 2.x
In the majority of cases, moving from version 1 to 2 is a very simple process:
1. Indent the whole file by one level and put a `services:` key at the top.
2. Add a `version: '2'` line at the top of the file.
It's more complicated if you're using particular configuration features:
- `dockerfile`: This now lives under the `build` key:
build:
context: .
dockerfile: Dockerfile-alternate
- `log_driver`, `log_opt`: These now live under the `logging` key:
logging:
driver: syslog
options:
syslog-address: "tcp://192.168.0.42:123"
- `links` with environment variables: environment variables created by
links, such as `CONTAINERNAME_PORT`, ` have been deprecated for some time. In the new Docker network system,
they have been removed. You should either connect directly to the
appropriate hostname or set the relevant environment variable yourself,
using the link hostname:
web:
links:
- db
environment:
- DB_PORT=tcp://db:5432
- `external_links`: Compose uses Docker networks when running version 2
projects, so links behave slightly differently. In particular, two
containers must be connected to at least one network in common in order to
communicate, even if explicitly linked together.
Either connect the external container to your app's
[default network](https://docs.docker.com/compose/networking/), or connect both the external container and
your service's containers to an
[external network](https://docs.docker.com/compose/networking/).
- `net`: This is now replaced by [network_mode](compose-file-v3.md#network_mode):
net: host -> network_mode: host
net: bridge -> network_mode: bridge
net: none -> network_mode: none
If you're using `net: "container:[service name]"`, you must now use
`network_mode: "service:[service name]"` instead.
net: "container:web" -> network_mode: "service:web"
If you're using `net: "container:[container name/id]"`, the value does not
need to change.
net: "container:cont-name" -> network_mode: "container:cont-name"
net: "container:abc12345" -> network_mode: "container:abc12345"
- `volumes` with named volumes: these must now be explicitly declared in a
top-level `volumes` section of your Compose file. If a service mounts a
named volume called `data`, you must declare a `data` volume in your
top-level `volumes` section. The whole file might look like this:
version: "{{% param "compose_file_v2" %}}"
services:
db:
image: postgres
volumes:
- data:/var/lib/postgresql/data
volumes:
data: {}
By default, Compose creates a volume whose name is prefixed with your
project name. If you want it to just be called `data`, declare it as
external:
volumes:
data:
external: true

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +0,0 @@
# The docs have been moved!
The documentation for Compose has been merged into
[the general documentation repo](https://github.com/docker/docker.github.io).
The docs for Compose are now here:
https://github.com/docker/docker.github.io/tree/master/compose
Please submit pull requests for unreleased features/changes on the `master` branch (https://github.com/docker/docker.github.io/tree/master), please prefix the PR title with `[WIP]` to indicate that it relates to an unreleased change.
If you submit a PR to this codebase that has a docs impact, create a second docs PR on `docker.github.io`. Use the docs PR template provided.
As always, the docs remain open-source and we appreciate your feedback and
pull requests!

437
logo.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 132 KiB

View File

@@ -1,10 +1,9 @@
Click==7.1.2
coverage==5.2.1
ddt==1.4.1
coverage==5.5
ddt==1.4.2
flake8==3.8.3
gitpython==3.1.11
mock==3.0.5
pytest==6.0.1; python_version >= '3.5'
pytest==6.2.4; python_version >= '3.5'
pytest==4.6.5; python_version < '3.5'
pytest-cov==2.10.1
PyYAML==5.3.1

View File

@@ -11,9 +11,9 @@ gitdb2==4.0.2
mccabe==0.6.1
more-itertools==8.6.0; python_version >= '3.5'
more-itertools==5.0.0; python_version < '3.5'
packaging==20.4
packaging==20.9
pluggy==0.13.1
py==1.9.0
py==1.10.0
pycodestyle==2.6.0
pycparser==2.20
pyflakes==2.2.0

View File

@@ -1,22 +1,22 @@
backports.shutil_get_terminal_size==1.0.0
cached-property==1.5.1
certifi==2020.6.20
cached-property==1.5.1; python_version < '3.8'
certifi==2021.5.30
chardet==3.0.4
colorama==0.4.3; sys_platform == 'win32'
colorama==0.4.4; sys_platform == 'win32'
distro==1.5.0
docker==4.4.4
docker==5.0.0
docker-pycreds==0.4.0
dockerpty==0.4.1
docopt==0.6.2
idna==2.10
ipaddress==1.0.23
jsonschema==3.2.0
paramiko==2.7.1
paramiko==2.7.2
PySocks==1.7.1
python-dotenv==0.14.0
pywin32==227; sys_platform == 'win32'
PyYAML==5.3.1
requests==2.24.0
texttable==1.6.2
urllib3==1.25.10; python_version == '3.3'
websocket-client==0.57.0
python-dotenv==0.17.0
pywin32==301; sys_platform == 'win32'
PyYAML==5.4.1
requests==2.25.1
texttable==1.6.3
urllib3==1.26.5; python_version == '3.3'
websocket-client==1.1.0

View File

@@ -20,4 +20,3 @@ This should trigger a new CI build on the new tag. When the CI finishes with the
4. In case of a GA version, please update `docker-compose`s release notes and version on [github documentation repository](https://github.com/docker/docker.github.io):
- [Release Notes](https://github.com/docker/docker.github.io/blob/master/compose/release-notes.md)
- [Config version](https://github.com/docker/docker.github.io/blob/master/_config.yml)
- [Config authoring version](https://github.com/docker/docker.github.io/blob/master/_config_authoring.yml)

0
script/release/release.py Executable file → Normal file
View File

View File

@@ -15,7 +15,7 @@
set -e
VERSION="1.28.5"
VERSION="1.26.1"
IMAGE="docker/compose:$VERSION"

View File

@@ -43,7 +43,6 @@ for version in $DOCKER_VERSIONS; do
--name "$daemon_container" \
--privileged \
--volume="/var/lib/docker" \
-v $DOCKER_CONFIG/config.json:/root/.docker/config.json \
-e "DOCKER_TLS_CERTDIR=" \
"docker:$version-dind" \
dockerd -H tcp://0.0.0.0:2375 $DOCKER_DAEMON_ARGS \
@@ -51,6 +50,11 @@ for version in $DOCKER_VERSIONS; do
docker exec "$daemon_container" sh -c "apk add --no-cache git"
# copy docker config from host for authentication with Docker Hub
docker exec "$daemon_container" sh -c "mkdir /root/.docker"
docker cp /root/.docker/config.json $daemon_container:/root/.docker/config.json
docker exec "$daemon_container" sh -c "chmod 644 /root/.docker/config.json"
docker run \
--rm \
--tty \

View File

@@ -25,14 +25,13 @@ def find_version(*file_paths):
install_requires = [
'cached-property >= 1.2.0, < 2',
'docopt >= 0.6.1, < 1',
'PyYAML >= 3.10, < 6',
'requests >= 2.20.0, < 3',
'texttable >= 0.9.0, < 2',
'websocket-client >= 0.32.0, < 1',
'distro >= 1.5.0, < 2',
'docker[ssh] >= 4.4.4, < 5',
'docker[ssh] >= 5',
'dockerpty >= 0.4.1, < 1',
'jsonschema >= 2.5.1, < 4',
'python-dotenv >= 0.13.0, < 1',
@@ -50,6 +49,7 @@ if sys.version_info[:2] < (3, 4):
extras_require = {
':python_version < "3.5"': ['backports.ssl_match_hostname >= 3.5, < 4'],
':python_version < "3.8"': ['cached-property >= 1.2.0, < 2'],
':sys_platform == "win32"': ['colorama >= 0.4, < 1'],
'socks': ['PySocks >= 1.5.6, != 1.5.7, < 2'],
'tests': tests_require,

View File

@@ -237,6 +237,11 @@ class CLITestCase(DockerClientTestCase):
result = self.dispatch(['-H=tcp://doesnotexist:8000', 'ps'], returncode=1)
assert "Couldn't connect to Docker daemon" in result.stderr
def test_config_list_profiles(self):
self.base_dir = 'tests/fixtures/config-profiles'
result = self.dispatch(['config', '--profiles'])
assert set(result.stdout.rstrip().split('\n')) == {'debug', 'frontend', 'gui'}
def test_config_list_services(self):
self.base_dir = 'tests/fixtures/v2-full'
result = self.dispatch(['config', '--services'])

View File

@@ -0,0 +1,15 @@
version: '3.8'
services:
frontend:
image: frontend
profiles: ["frontend", "gui"]
phpmyadmin:
image: phpmyadmin
depends_on:
- db
profiles:
- debug
backend:
image: backend
db:
image: mysql

1
tests/fixtures/env-file-override/.env vendored Normal file
View File

@@ -0,0 +1 @@
WHEREAMI=default

View File

@@ -1,5 +1,6 @@
import tempfile
import pytest
from ddt import data
from ddt import ddt
@@ -8,6 +9,7 @@ from ..acceptance.cli_test import dispatch
from compose.cli.command import get_project
from compose.cli.command import project_from_options
from compose.config.environment import Environment
from compose.config.errors import EnvFileNotFound
from tests.integration.testcases import DockerClientTestCase
@@ -55,13 +57,36 @@ services:
class EnvironmentOverrideFileTest(DockerClientTestCase):
def test_env_file_override(self):
base_dir = 'tests/fixtures/env-file-override'
# '--env-file' are relative to the current working dir
env = Environment.from_env_file(base_dir, base_dir+'/.env.override')
dispatch(base_dir, ['--env-file', '.env.override', 'up'])
project = get_project(project_dir=base_dir,
config_path=['docker-compose.yml'],
environment=Environment.from_env_file(base_dir, '.env.override'),
environment=env,
override_dir=base_dir)
containers = project.containers(stopped=True)
assert len(containers) == 1
assert "WHEREAMI=override" in containers[0].get('Config.Env')
assert "DEFAULT_CONF_LOADED=true" in containers[0].get('Config.Env')
dispatch(base_dir, ['--env-file', '.env.override', 'down'], None)
def test_env_file_not_found_error(self):
base_dir = 'tests/fixtures/env-file-override'
with pytest.raises(EnvFileNotFound) as excinfo:
Environment.from_env_file(base_dir, '.env.override')
assert "Couldn't find env file" in excinfo.exconly()
def test_dot_env_file(self):
base_dir = 'tests/fixtures/env-file-override'
# '.env' is relative to the project_dir (base_dir)
env = Environment.from_env_file(base_dir, None)
dispatch(base_dir, ['up'])
project = get_project(project_dir=base_dir,
config_path=['docker-compose.yml'],
environment=env,
override_dir=base_dir)
containers = project.containers(stopped=True)
assert len(containers) == 1
assert "WHEREAMI=default" in containers[0].get('Config.Env')
dispatch(base_dir, ['down'], None)

View File

@@ -25,6 +25,7 @@ from compose.const import COMPOSE_SPEC as VERSION
from compose.const import LABEL_PROJECT
from compose.const import LABEL_SERVICE
from compose.container import Container
from compose.errors import CompletedUnsuccessfully
from compose.errors import HealthCheckFailed
from compose.errors import NoHealthCheckConfigured
from compose.project import Project
@@ -1899,6 +1900,106 @@ class ProjectTest(DockerClientTestCase):
with pytest.raises(NoHealthCheckConfigured):
svc1.is_healthy()
def test_project_up_completed_successfully_dependency(self):
config_dict = {
'version': '2.1',
'services': {
'svc1': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'true'
},
'svc2': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'top',
'depends_on': {
'svc1': {'condition': 'service_completed_successfully'},
}
}
}
}
config_data = load_config(config_dict)
project = Project.from_config(
name='composetest', config_data=config_data, client=self.client
)
project.up()
svc1 = project.get_service('svc1')
svc2 = project.get_service('svc2')
assert 'svc1' in svc2.get_dependency_names()
assert svc2.containers()[0].is_running
assert len(svc1.containers()) == 0
assert svc1.is_completed_successfully()
def test_project_up_completed_unsuccessfully_dependency(self):
config_dict = {
'version': '2.1',
'services': {
'svc1': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'false'
},
'svc2': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'top',
'depends_on': {
'svc1': {'condition': 'service_completed_successfully'},
}
}
}
}
config_data = load_config(config_dict)
project = Project.from_config(
name='composetest', config_data=config_data, client=self.client
)
with pytest.raises(ProjectError):
project.up()
svc1 = project.get_service('svc1')
svc2 = project.get_service('svc2')
assert 'svc1' in svc2.get_dependency_names()
assert len(svc2.containers()) == 0
with pytest.raises(CompletedUnsuccessfully):
svc1.is_completed_successfully()
def test_project_up_completed_differently_dependencies(self):
config_dict = {
'version': '2.1',
'services': {
'svc1': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'true'
},
'svc2': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'false'
},
'svc3': {
'image': BUSYBOX_IMAGE_WITH_TAG,
'command': 'top',
'depends_on': {
'svc1': {'condition': 'service_completed_successfully'},
'svc2': {'condition': 'service_completed_successfully'},
}
}
}
}
config_data = load_config(config_dict)
project = Project.from_config(
name='composetest', config_data=config_data, client=self.client
)
with pytest.raises(ProjectError):
project.up()
svc1 = project.get_service('svc1')
svc2 = project.get_service('svc2')
svc3 = project.get_service('svc3')
assert ['svc1', 'svc2'] == svc3.get_dependency_names()
assert svc1.is_completed_successfully()
assert len(svc3.containers()) == 0
with pytest.raises(CompletedUnsuccessfully):
svc2.is_completed_successfully()
def test_project_up_seccomp_profile(self):
seccomp_data = {
'defaultAction': 'SCMP_ACT_ALLOW',

View File

@@ -2397,7 +2397,8 @@ web:
'image': 'busybox',
'depends_on': {
'app1': {'condition': 'service_started'},
'app2': {'condition': 'service_healthy'}
'app2': {'condition': 'service_healthy'},
'app3': {'condition': 'service_completed_successfully'}
}
}
override = {}
@@ -2409,11 +2410,12 @@ web:
'image': 'busybox',
'depends_on': {
'app1': {'condition': 'service_started'},
'app2': {'condition': 'service_healthy'}
'app2': {'condition': 'service_healthy'},
'app3': {'condition': 'service_completed_successfully'}
}
}
override = {
'depends_on': ['app3']
'depends_on': ['app4']
}
actual = config.merge_service_dicts(base, override, VERSION)
@@ -2422,7 +2424,8 @@ web:
'depends_on': {
'app1': {'condition': 'service_started'},
'app2': {'condition': 'service_healthy'},
'app3': {'condition': 'service_started'}
'app3': {'condition': 'service_completed_successfully'},
'app4': {'condition': 'service_started'},
}
}
@@ -3567,9 +3570,11 @@ class InterpolationTest(unittest.TestCase):
@mock.patch.dict(os.environ)
def test_config_file_with_options_environment_file(self):
project_dir = 'tests/fixtures/default-env-file'
# env-file is relative to current working dir
env = Environment.from_env_file(project_dir, project_dir + '/.env2')
service_dicts = config.load(
config.find(
project_dir, None, Environment.from_env_file(project_dir, '.env2')
project_dir, None, env
)
).services
@@ -5233,6 +5238,8 @@ class GetDefaultConfigFilesTestCase(unittest.TestCase):
files = [
'docker-compose.yml',
'docker-compose.yaml',
'compose.yml',
'compose.yaml',
]
def test_get_config_path_default_file_in_basedir(self):
@@ -5266,8 +5273,10 @@ def get_config_filename_for_files(filenames, subdir=None):
base_dir = tempfile.mkdtemp(dir=project_dir)
else:
base_dir = project_dir
filename, = config.get_default_config_files(base_dir)
return os.path.basename(filename)
filenames = config.get_default_config_files(base_dir)
if not filenames:
raise config.ComposeFileNotFound(config.SUPPORTED_FILENAMES)
return os.path.basename(filenames[0])
finally:
shutil.rmtree(project_dir)

View File

@@ -330,7 +330,7 @@ class ServiceTest(unittest.TestCase):
assert service.options['environment'] == environment
assert opts['labels'][LABEL_CONFIG_HASH] == \
'689149e6041a85f6fb4945a2146a497ed43c8a5cbd8991753d875b165f1b4de4'
'6da0f3ec0d5adf901de304bdc7e0ee44ec5dd7adb08aebc20fe0dd791d4ee5a8'
assert opts['environment'] == ['also=real']
def test_get_container_create_options_sets_affinity_with_binds(self):
@@ -700,6 +700,7 @@ class ServiceTest(unittest.TestCase):
config_dict = service.config_dict()
expected = {
'image_id': 'abcd',
'ipc_mode': None,
'options': {'image': 'example.com/foo'},
'links': [('one', 'one')],
'net': 'other',
@@ -723,6 +724,7 @@ class ServiceTest(unittest.TestCase):
config_dict = service.config_dict()
expected = {
'image_id': 'abcd',
'ipc_mode': None,
'options': {'image': 'example.com/foo'},
'links': [],
'networks': {},

View File

@@ -50,7 +50,7 @@ directory = coverage-html
[flake8]
max-line-length = 105
# Set this high for now
max-complexity = 11
max-complexity = 12
exclude = compose/packages
[pytest]