Docker compose can be run in detached mode and you can attach to the logs of all container later.
If you’re done watching logs you can detach yourself from the logs output without shutting down your services.
docker-compose up -dto start all services in detached mode (
-d) (you won’t see any logs in detached mode)
docker-compose logs -f -tto attach yourself to the logs of all running services, whereas
-fmeans you follow the log output and the
-toption gives you nice timestamps (See Docker reference)
Ctrl + zor
Ctrl + cto detach yourself from the log output without shutting down your services
If you’re interested in a single container you can use the
docker keyword instead:
docker logs -t -f <container-name>