Open max-cole opened 1 year ago
watch
indeed takes place after the compose file and related files have been parsed. It will neither re-create container with an updated config if you change anything in yaml. That's probably confusing, but with current architecture I don't expect this to be feasible. cc @milas
How about an action type of recreate
to support the following?
# ...
watch:
- action: recreate
path: compose.yaml
- action: sync
path: ./web
target: /src/web
ignore:
- node_modules/
- action: rebuild
path: package.json
Then, if I edit actions or a port on a service definition, watch can trigger docker compose up -d
or similar.
That sounds great! I think that solution would work well for env files:
Ex in our local dev setup we have a folder with several env files for the services so its
~/local-dev/
~/local-dev/env/
~/local-dev/env/service1.env
~/local-dev/env/service2.env
I would love for a self-referential in the docker-compose file but that's a somewhat bigger ask something like:
services:
service1:
[...]
watch:
recreate-on-change: true
But the work around to simply put the compose.yaml into any service's watch section would work totally fine and be more in spirit with the rest of this work. Thanks!
Description
When using the
docker compose alpha watch
command if you make a change to the env_files in the docker-compose.yaml or change the docker-compose.yaml file itself and let a file change trigger the rebuild functionality those changes are not used during the rebuild.Steps To Reproduce
Working Docker Desktop
Use the following Config.
docker-compose.yaml
web.env
If you do a
docker compose up -d
the web container will be created withVALUE=1
as an env-var.You can then start a
docker compose alpha watch
to make your changes.If you change
VALUE=1
toVALUE=2
in the .env file this will not trigger a rebuild (as expected we are not watching that file) and if you do adocker-compose up -d
the container will be recreated with the new value. However if you don't stop the watch and it triggers a rebuild the container will be recreated with the value at the time thedocker compose alpha watch
was started.This also works if you have the watch include the .env file, the container will be recreated with whatever was in the .env file at the time of the
docker compose alpha watch
command was started.If you change the config of the docker-compose.yaml file this also does not get carried over when the rebuild starts.
docker-compose.yaml
Triggering a rebuild via the watch functionality creates a new container without the
name=value
env-var unless you also restart the watch command.Expected Behavior:
The watch command should rebuild the full config of the container including any changes to configs whenever a rebuild is triggered.
When I make a change to the env file I do not expect the rebuild to trigger if I'm not including that in my watch config, however when that rebuild does happen I would expect that the
most current
config would be used to rebuild the container not the config that was in place when thedocker compose alpha watch
command was started.Compose Version
Docker Environment
Anything else?
No response