I couldn’t find a simple a posteriori method to find the docker-composer launching directory, but you could create a wrapper script to register that operation in a log stored in a known location. As an example, lets make an script in /usr/local/bin/dkcompose.sh as follows:
# register docker-compose commands and where they were launched.
NOW=$(date '+%F %T')
echo "$NOW Directory: $DIR" >> $LOG
echo "$NOW Command: docker-compose $*" >> $LOG
#-- end --#
Don’t forget to chmod a+rx /usr/local/bin/dkcompose.sh to allow execution of the script. As the script is in a directory in the $PATH variable can be called from anywhere, so you could say
And the script will store the following in the LOG file before calling docker-compose:
2018-05-05 14:18:23 Directory: /projects/myproyect2
2018-05-05 14:18:23 Command: docker-compose up
Using the script in this way you will log any docker-compose command and when and where it was executed.
PORTABILITY: If you use a distinct shell from Bash, change the first line to identify your shell and $(command) expressions with backticks: `command`. If you cannot put the script in a global directory in the $PATH, put it in your home directory, apply the chmod a+rx to it and then call it directly from anywhere with: