Docker containers exit by default if no process is running on them. tail -f is an ongoing process, so it will run indefinitely and prevent the container from stopping. So to avoid this error you can add default entrypoint which will override to keep the container running state.
You can add this below entry in your docker-compose file.
entrypoint: tail -f /dev/null