this post was submitted on 02 Sep 2024
8 points (100.0% liked)

Docker

1080 readers
1 users here now

founded 1 year ago
MODERATORS
 

I have a docker compose file with a bind volume. It basically mounts /media/user/drive/media to the container's /mnt.

It works as expected when /media/user/drive/ is mounted and its media folder has the files I want the container to see.

However, as it's a network drive, the container usually tries to start before it is mounted, so it would throw the error that /media/user/drive/media doesn't exist. So I created an empty folder in /media/user/drive called media while the drive was not mounted so that at least the container starts with the volume /mnt being empty until the network drive gets mounted and all the files appear at /media/user/drive/media.

To my surprise, when the drive gets mounted, even though if I do ls /media/user/drive/media it lists the drive contents correctly, the container still sees /mnt empty.

How would I go about getting the drive files inside the docker container when it automatically starts?

you are viewing a single comment's thread
view the rest of the comments
[–] Nomecks@lemmy.ca 1 points 2 weeks ago (3 children)

If the container is running under a different user then you may have some permission issues.

[–] k2helix@lemmy.world 1 points 2 weeks ago (1 children)

Don't think it has to do with permissions as if I manually start the container after the drive gets mounted then everything goes as expected and the container has the files at /mnt

[–] Nomecks@lemmy.ca 1 points 2 weeks ago (1 children)

Pop a script on the container to do a whoami and an ls -l on the folder

[–] k2helix@lemmy.world 2 points 2 weeks ago

I managed to solve it by automatically restarting the container once the drive is mounted, as the mount is done by a systemd service. Guess there were no permission issues

load more comments (1 replies)