I have a Docker container \"A\" that will start another container \"B\" (by volume mounting /var/run/docker.sock). Now, these containers need to share files.
Container \
If you do not rely on volumes, another way to share files would be to pipe them from "A" to "B". You would need container B to handle input on STDIN, ex. with a custom entrypoint.
In container A:
cat some_file_on_A.txt | docker run -i container_B
Example entrypoint in container B:
while read input_from_A; do
echo "${input_from_A}" > some_file_on_B.txt
done