Reputation: 317
I'm trying to mount a directory in my organization's server (Y:/some/path
) to a docker container. My docker-compose.yml
looks like this:
services:
dagit:
volumes:
- type: bind
source: Y:/some/path
target: /data
build:
context: .
dockerfile: Dagit.Dockerfile
ports:
- "3000:3000"
container_name: dagit-container
dagster:
volumes:
- type: bind
source: Y:/some/path
target: /data
build:
context: .
dockerfile: Daemon.Dockerfile
container_name: dagster-container
tty: true
env_file: .env
I have shared Y:/some/path
with Docker. On docker compose up -d --build
, I get the following error: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /host_mnt/uC/my_ip/some/path
. How can I properly mount such a directory? Also, what would be the correct way to declare this mount in the top level volumes
key and reference it in both services so I don't have to duplicate the code?
Upvotes: 1
Views: 3589
Reputation: 1940
Assuming your enterprise share is Windows/SAMBA CIFS/SMB-Share, add it as Volume directly and not via Windows mount.
volumes:
shared_folder:
driver_opts:
type: cifs
o: username=smbuser,password=smbpass,uid=UID for mount,gid=gid for mount,vers=3.0,rw
device: //hostname_or_ip/folder
Version depends on your Server Type, rw = readwrite Then map the volume
services:
dagit:
volumes:
- shared_folder:/root/data
Upvotes: 2
Reputation: 2666
Take the following docker-compose.yml file:
version: '3.9'
services:
DockerA:
image: ubuntu:latest
container_name: DockerA
command: ["sleep", "300d"]
volumes:
- "./data:/root/data"
DockerB:
image: ubuntu:latest
container_name: DockerB
command: [ "sleep", "300d" ]
volumes:
- "./data:/root/data"
volumes:
data:
And next to that file (same directory) create a directory called 'data'.
Now start the dockers with:
docker-compose up -d
If you enter the DockerA container and create something in the data directory:
docker exec -it DockerA /bin/bash
# cd /root/data
# echo "Hello World!" > x.txt
then go into DockerB
docker exec -it DockerB /bin/bash
# cd /root/data
# cat x.txt
you will see the same contents of x.txt.
Now back to the host and check the x.txt file in your ./data directory. Also same contents.
If you edit x.txt on the Host, it will immediatelly be reflected in both DockerA and DockerB.
Upvotes: 2