docker / compose

Define and run multi-container applications with Docker
https://docs.docker.com/compose/
Apache License 2.0
34.11k stars 5.25k forks source link

Watch: sync+reload mode #12318

Open torarnv opened 1 day ago

torarnv commented 1 day ago

Description

Sometimes the container supports explicit reloads of the config. E.g. Caddy can do caddy reload --config /etc/caddy/Caddyfile

In this mode the container doesn't need to be restarted, it's enough to do sync+reload (not sync+restart).

Would be nice if there was a sync+reload mode where a custom reload command could be provided.

Not having to restart the container would mitigate issues like https://github.com/docker/compose/issues/12317

ndeloof commented 22 hours ago

For your use-case, we could introduce:

      watch: 
        - path: ./webapp/html
          action: sync+exec
          target: /var/www
          exec: <command to run in container by docker exec ...>

note: A comparable use-case could require to send a signal to container, typically SIGHUP to force a reset/reconfiguration of the service. Container's entrypoint could catch such a signal to run a custom command

torarnv commented 22 hours ago

An explicit exec would work, good idea!

Container's entrypoint could catch such a signal to run a custom command

I think a requirement for such a feature is that the container doesn't need any modification, ie custom entrypoint, to be able to be "watchable" by docker compose.

But yes, if the container already reacts to e.g. SIGHUP, then the exec part could be a signal. How would the exec know which process to signal? I guess it's the only one running in the container?

ndeloof commented 21 hours ago

sure, this was just a note about a comparable feature request, not a XOR statement