-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: One-off tasks #7539
Comments
I like the idea compose file format can be used to define tasks/jobs that are expected to stop after completion, but imho this is orthogonal to the initial intent to only run some of them in a specific context. For this purpose, I'd prefer a "profile" approach like I used to do with Apache Maven on java projects: Just like docker-compose by default will load a docker-compose-override.yaml file if it exists aside the main yaml config, we can introduce support for i.e so, your sample becomes:
or
This is indeed the right place to have this discussion :) |
(copying from a slack conversation we had) Alternatively we could make "profile" a property of services/objects. Implicitly all objects would be in the For example, a service that has: profiles: ["debug"] Would only be started if the profiles: ["default", "prod"] Would be started if either no profile was selected, or the The above would facilitate "run definitions"; e.g., services that are defined in the compose-file but "never" run automatically. This could be achieved by setting a "dummy" profile (e.g. At the same time, it would allow for a "set" of tasks to be specified that can be run as a group, e.g. setting profile Note: "profile" as a name would have to be looked at; there also was a proposal somewhere to have "container profiles" that allowed certain default configurations for a container, so we need to look carefully if "profile" is the best name. |
I am thinking of this primarily from a user's point of view. I can understand how profiles might make sense from an architectural point of view, but from a user's point of view, frankly it is confusing and doesn't map with my intent. I have a test script, and I want to run the test script. I'm not switching between modes or profiles. Could you explain profiles to me as if I were a user? How would I use them to implement my example above, step-by-step? Perhaps another way of helping me understand: What other use-cases are there for profiles? replicate.yaml examples of those use-cases would be helpful too. |
From a user point of view, I agree "profiles" can smell over-engineering, maybe could be considered separately as a generic improvement to flexibility. Regarding your proposal, I'm just concerned with the use of Alternatively, with lower (?) impacts, "services" could also get a new |
Implement profiles as introduced in compose-spec/compose-spec#110 fixes docker#7919 closes docker#1896 closes docker#6742 closes docker#7539
Implement profiles as introduced in compose-spec/compose-spec#110 fixes docker#7919 closes docker#1896 closes docker#6742 closes docker#7539 Signed-off-by: Roman Anasal <[email protected]>
Implement profiles as introduced in compose-spec/compose-spec#110 fixes docker#7919 closes docker#1896 closes docker#6742 closes docker#7539 Signed-off-by: Roman Anasal <[email protected]>
Implement profiles as introduced in compose-spec/compose-spec#110 fixes docker#7919 closes docker#1896 closes docker#6742 closes docker#7539 Signed-off-by: Roman Anasal <[email protected]>
Implement profiles as introduced in compose-spec/compose-spec#110 fixes docker#7919 closes docker#1896 closes docker#6742 closes docker#7539 Signed-off-by: Roman Anasal <[email protected]>
Implement profiles as introduced in compose-spec/compose-spec#110 fixes docker#7919 closes docker#1896 closes docker#6742 closes docker#7539 Signed-off-by: Roman Anasal <[email protected]>
I agree with @bfirsh that profiles do not solve the problem. I can use container to run one-off task, but after container exits it keeps hanging in the list of services. |
they don't, but offer a workaround for a pseudo-service definition to only be used by explicit
can you please clarify what you see and would expect here ? |
@ndeloof , here's what I mean: I'd like to have an option to at least show the status as Ok (Green, not Orange) |
ok, Docker desktop "compose" view is very minimalist and indeed doesn't distinguish one-off container vs services. I wish those get indeed a distinct style and/or could be filtered out. Could you maybe open a feature request on https://github.com/docker/for-mac ? |
Done it here |
Background & problem
Users quite often define maintenance scripts, test suites, debugging systems in their Compose files which they don't want to run when they do
docker-compose up
.Personally, this is something I've wanted since almost the start. My daily paper cut is writing
docker-compose run web ./test.sh
instead ofdocker-compose run test
.I wrote a diplomatic aggregation of potential solutions and data points in #1896. This is an opinionated proposed solution we can use as a strawman.
Proposed solution
I propose we add a top-level
tasks
configuration option, which takes the same options as theservices
option. It's a bit like a service, but doesn't start when you rundocker-compose up
. It only works withdocker-compose run
. Service and task names must be unique so they don't collide.As an example, let's add a task to the Django getting started guide app:
You would run the tests by running
docker-compose run test
.Because we've specified
entrypoint
in the task definition, we can also pass arguments to the tests:docker-compose run test myapp/test_views.py
Questions
tasks
is a nice bike shed -- go at itentrypoint
instead ofcommand
is a bit clumsy. Users will automatically writecommand
then wonder why their arguments aren't working as expected. Maybe there is a better solution here?/cc @aanand @shin- in case there is any historical knowledge I am not aware of. (hi!)
The text was updated successfully, but these errors were encountered: