You’ve pretty much answered it yourself in the example you gave: you can mount the host’s relative path ./ to an absolute path /data in the compose file, and the container will mount the $CWD at launch as /data.
I think most bind mounts are default read-only, which is why your write is failing. Try adding ,rw
to the end of the list entry in volumes
and see if that helps.
edit: another poster got it with working_dir
which also is more right
Using relative paths is bad practice, by the way. It’s fine for development and testing, but in production you would want always to use absolute paths. Think of it as a bad habit that leaves surprises for yourself and othere down the road when moving or replicating projects. If you want it to be more dynamic, consider using compose vars and environment variables
Another thing you might want to consider is not mounting the project root as a RW filesystem in your containers, since this allows the container to modify its own compose file. That’s rarely something you’d want to do. Better to make a subdirectory for each container in the project folder, and mount those into the appropriate contains
It is absolutely too soon for remarks like this, but I can’t help but be amused by ISIS having their “nOTicE mE SEmPai!” moment.
My heart goes out to the victims and their families, and my spite to the rest of the lot.