- Docker: Mount external drive to a volume and attach it to a container
docker volume create --name fred --opt /media/pi/mydrive
docker run -v fred:/var/www/html/ <container>
- Docker: Mount directory from one container to another (specific dir)
Mount using
--volumes-from:
docker run -v /data/myfolder --name container1 image-name-1
docker run --volumes-from container1 image-name-2
Mount a specific dir:
# load directories in variables:
SRV1=$(docker inspect DATA1 | grep "vfs/dir" | awk '/"(.*)"/ { gsub(/"/,"",$2); print $2 }')
SRV2=$(docker inspect DATA2 | grep "vfs/dir" | awk '/"(.*)"/ { gsub(/"/,"",$2); print $2 }')
# mount these volumes by real directories instead of the --volumes-from
docker run -t -i -v $SRV1:/srv1 -v $SRV2:/srv2 ubuntu bash