Bind mounting files from host to sibling containers over docker.sock fails. Bug? Way Forward?

Hello,
I am trying to dockerize an application that launches and controls other docker containers. This application uses compose files to launch the other needed containers. I am doing this by mounting the docker socket in the container. In order for this to work I am updating the compose files the application uses to launch the other containers so that the volumes and mounts are correctly referencing locations on the host and not in the container the application is running in. This is working well, and It is launching sibling containers on the host.

I am hitting a roadblock though when this application needs to launch containers with individual files bind mounted from the host into the containers, from discussion here: docker - How to mount a single file in a volume - Stack Overflow
I see that for bind mounts docker first checks for the files/directories existence and if not found it attempts to create a directory there. The issue is that this check assumes the reference is local on the container and not on the host and so it always fails, even though if it passed and used the docker sock context to launch the container it would find the file on the host.

Because of this I am getting an unknown file error. What is the correct approach here? This seems like a bug to me that this check ignores the context it is being run with. How can I get around this and mount files from the host to the sibling containers like I can with volumes?

let’s simplify it:

  1. Imagine Shared Files:
  • Think of files on your computer like documents you want to share.
  1. Docker Containers as Rooms:
  • Picture Docker containers as separate rooms where different things happen.
  1. Trying to Share Files:
  • You want to share these files between rooms, so you try to connect them using something like a special door (docker.sock).
  1. Issue with Sharing:
  • But, oops, the door doesn’t seem to work properly. Your files can’t move between rooms like you expected.
  1. Possible Bug:
  • There might be a problem, a bug, that’s causing this door (docker.sock) not to work as intended.
  1. What to Do Next:
  • You could try to investigate the issue further, maybe check if there’s a solution or workaround. It’s like trying to fix a door that’s not opening correctly.
  1. Check Docker Documentation:
  • Look into the Docker documentation to see if there are any guidelines or known issues about sharing files between containers using docker.sock.
  1. Community Support:
  • Reach out to the Docker community or forums. Others might have faced the same issue and could share their experiences or solutions.
  1. Consider Alternatives:
  • If the door (docker.sock) is really causing trouble, consider alternative ways to share files between containers. There might be different doors that work better for your situation.
  1. Stay Updated:
  • Keep an eye on updates or fixes from Docker. Bugs often get patched, and newer versions might resolve the issue.

Maybe share Dockerfiles and docker-compose.yml you are using.