You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running docker compose up --watch, the logs for the service appear in the output.
When specifying sync+restart as the action on a file change, when a file is changed, the container restarts, but there are no more logs outputted. When running docker compose logs, you can see the app was restarted correctly and is still logging.
This behaviour does not happen when using rebuild as the action (although the logs aren't picked up straight away so the first logs are potentially missed).
Expected behaviour is that when using sync+restart, when a file is changed, the logs from the container continue to be shown in the output of docker compose up --watch.
If you change sync+restart to rebuild in the docker-compose file, and run docker compose up --watch, and save a file, it now prints (most of) the logs correctly:
➜ docker compose up --watch
[+] Running 1/2
✔ Network docker-compose-watch_default Created 0.1s
⠧ Container docker-compose-watch-app-1 Created 0.7s
⦿ Watch enabled
Attaching to app-1
app-1 | restart
app-1 | boop 0
app-1 | boop 1
app-1 | boop 2
app-1 | boop 3
app-1 | boop 4
app-1 | boop 5
⦿ Rebuilding service "app" after changes were detected...
app-1 | boop 6
⦿ service "app" successfully built
app-1 exited with code 0
app-1 has been recreated
app-1 | boop 2
app-1 | boop 3
app-1 | boop 4
app-1 | boop 5
app-1 | boop 6
Note that in the output, it misses the first few logs.
Doing a docker compose logs only shows the logs for the latest container.
Compose Version
➜ docker compose version
Docker Compose version v2.26.1
```sh
➜ docker-compose version
docker-compose version 1.29.2, build 5becea4c
docker-py version: 5.0.0
CPython version: 3.7.10
OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019
Similar behavior happens when sending a docker compose up --watch job to the background and watching the output with docker compose logs --follow in another command window. The service logs show up until the service restart occurs, after which the logs command exits with code 0. One might expect docker compose logs --follow to show the sync/restart messages along with the rest of the output from the restarted (or terminated and started again) service.
I think this happens when the number of running services drops to zero, even if temporarily for a restart. For example, if you start two services but one exits due to an error, this issue will occur when the other one is restarted.
I was able to work around this issue for now by keeping a dummy service alive at all times:
Description
When running
docker compose up --watch
, the logs for the service appear in the output.When specifying
sync+restart
as the action on a file change, when a file is changed, the container restarts, but there are no more logs outputted. When runningdocker compose logs
, you can see the app was restarted correctly and is still logging.This behaviour does not happen when using
rebuild
as the action (although the logs aren't picked up straight away so the first logs are potentially missed).Expected behaviour is that when using
sync+restart
, when a file is changed, the logs from the container continue to be shown in the output ofdocker compose up --watch
.Steps To Reproduce
Dockerfile:
Contents of
src
can be anything.Docker Compose:
Running
docker compose up --watch
, then saving a file insrc
outputs:When running
docker compose logs
, it shows all the logs correctly.If you change
sync+restart
torebuild
in the docker-compose file, and rundocker compose up --watch
, and save a file, it now prints (most of) the logs correctly:Note that in the output, it misses the first few logs.
Doing a
docker compose logs
only shows the logs for the latest container.Compose Version
Anything else?
Feature introduction and demo
The text was updated successfully, but these errors were encountered: