Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single file volume mounts not behaving the same as on macOS #1496

Open
jamesmcguirepro opened this issue May 22, 2024 · 2 comments
Open

Single file volume mounts not behaving the same as on macOS #1496

jamesmcguirepro opened this issue May 22, 2024 · 2 comments

Comments

@jamesmcguirepro
Copy link

jamesmcguirepro commented May 22, 2024

I have a docker-compose.yml that has a single file mounted as a volume that works fine on MacOS hosts.

ie:

---
version: '3'
...
    volumes:
    - "./volumes/init_script.sh:/some_folder/init_script.sh"
...

However, when I try this on a linux machine, the file is incorrectly mounted as a directory, which breaks my image.

@thaJeztah
Copy link
Member

Bind-mounts happen on the daemon side, and default to assuming the path given is a directory. If your daemon is running remotely and doesn't have a file at the given location, and you're using the shorthand form for bind-mounts (<source>:<destination>), the daemon will automatically create the location on the host (which will be a directory), and bind-mount that in the container.

While on macOS, the daemon is also running "remotely" (in a VM) Docker Desktop makes sure that the files you're bind-mounting are present inside the VM before running the container.

@jamesmcguirepro
Copy link
Author

Yeah, I think that tracks, except the file exists at the given location. Perhaps linux is having trouble finding the file or with the relative path (./) when dealing with a single file mount?

Moving the file to the some_scripts directory and mounting the directory like this seems to work fine on linux:

---
version: '3'
...
    volumes:
    - "./volumes/some_scripts/:/some_folder/"
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants