SamuelKDavis
SamuelKDavis

Reputation: 1062

Is it possible to view docker-compose logs in the output window running in Windows?

docker-compose on Windows is not able to be run in interactive mode.

ERROR: Interactive mode is not yet supported on Windows.
Please pass the -d flag when using `docker-compose run`.

When running docker-compose in detached mode, little is displayed to the console, and the only logs displayed under docker-compose logs appear to be:

Attaching to

which obviously isn't very useful.

Is there a way of accessing these logs for transient containers?

I've seen that it's possible to change the docker-daemons logging to use a file (without the ability to select the log location). Following this as a solution I could log to the predefined log location, then execute a copy script to move the files to a mounted volume to be persisted before the container is torn down. This doesn't sound ideal.

The solution I've currently gone with (also not ideal) is to wrap the shell script parameter in a dynamically created proxy script which logs all output to the mounted volume.

tempFile=myproxy.sh

echo '#!/bin/bash' > $tempFile
echo 'do.the.thing.sh 2> /data/log.txt'>>$tempFile
echo 'echo finished >> /data/logs/log.txt' >> $tempFile

Which then I'd call

docker-compose run -d doTheThing $tempFile 

instead of

docker-compose run -d doTheThing do.the.thing.sh

Upvotes: 1

Views: 835

Answers (1)

dnephin
dnephin

Reputation: 28150

docker-compose logs doTheThing

Upvotes: 1

Related Questions