compose icon indicating copy to clipboard operation
compose copied to clipboard

[IDEA] docker compose up --watch

Open olivierdalang opened this issue 1 year ago • 3 comments

Description

I love the new watch feature !! Thanks !!!

However I feel it could be better integrated in the docker compose workflow.

From what I understand:

  • docker compose watch runs docker compose up --build -d beforehand
  • docker compose watch --no-up doesn't start the stack at all so it can be started separately

The first is convenient, but lacks all the flexibility of docker compose up (optional --build, --remove-orphans, --force-recreate, --profiles, etc.). The second provides all needed flexibility but requires two distinct commands as stated in #11157 (which was closed as doable with docker compose watch --no-up & docker compose up)

What about adding the --watch flag to docker compose up (and maybe deprecating/dropping the whole docker compose watch subcommand) ? Not sure about implementation, but from an user point of view it certainly would feel more natural.

olivierdalang avatar Jan 19 '24 09:01 olivierdalang

I was about to post this idea too!

It's annoying that I have to build all images every time I do docker compose watch so I thought maybe it could have the same default functionality as docker compose up? This means, only build images if no images are already built, or force builds with --build. We can have that and only modify the watch command, or as OP said, have docker compose up --watch which I suppose is the same as what I've described, just for the up command. Or both 🙃

Also, I would like to take the opportunity and ask mods to see https://github.com/docker/compose/issues/11098#issuecomment-1898452970 and hopefully reopen the issue!

PAXANDDOS avatar Jan 19 '24 14:01 PAXANDDOS

+1

I would like to be able to auto-reload containers which use a volume mount, by defining watch rule in the compose file, preferably without running in a special mode

currently I get error "can't watch service "stepfunctions" without a build context" when trying to use it with the amazon/aws-stepfunctions-local mock tool which has a config file you need to pass in via volume path

it seems that it only works for containers that have a build directive? This isn't spelled out in the docs AFAICT

also it's a bit confusing how watch + action: sync relates to volumes... seems like a separate new way to share files into the container?

anentropic avatar Mar 14 '24 22:03 anentropic

This seems to have been implemented now: https://github.com/docker/compose/pull/11525

remcokranenburg avatar May 01 '24 14:05 remcokranenburg