Answers for "How to redirect docker-compose command stdout stderr from docker container to file"

0

How to redirect docker-compose command stdout stderr from docker container to file

# start-cluster.sh
exec node cluster.js >> /var/log/cluster/console.log 2>&1
And in docker-compose file:

# docker-compose.yml
command: bash -c "./start-cluster.sh"
Starting the cluster with exec replaces the shell with node process and this way it has always PID=1 and my logs are output to file.
Posted by: Guest on March-24-2022
0

How to redirect docker-compose command stdout stderr from docker container to file

#!/bin/sh

# redirect stdout and stderr to files
exec >/tmp/stdout.log
exec 2>/tmp/stderr.log

# now run the requested CMD without forking a subprocess
exec "$@"
Posted by: Guest on March-24-2022

Code answers related to "How to redirect docker-compose command stdout stderr from docker container to file"

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language