'Mounting local volumes to remote docker container, Possible?
I'm pretty comfortable using Docker recently, typically to test websites to make sure they run properly on servers before I deploy them.
Typically, I mount my local directory to the locally running image like:
docker run -v c:\temp\website:/var/www/html (you get the picture)
What I am curious about is if there is a way to mount my local volume to a remote server running docker. I'm pretty sure the answer is no, unless I poke wholes in firewalls and such to make a local volume share externally.
But, I thought I would ask. Docker seems to be doing some amazing things quickly.
Solution 1:[1]
- First share your local directory in Windows. Lets assume your shared folder is
\\windowsip\website
. - Then login into the remote linux machine where docker engine is running, and be sure you can mount a windows shared folder:
sudo apt install cifs-utils
- Try to connect to your share:
sudo mount -t cifs -o user=******,password=******,uid=ubuntu,gid=ubuntu //windowsip/website /home/ubuntu/website
- When everything is working lets do the same with docker. Create a named volume as follows:
docker volume create --driver local --opt type=cifs --opt device='//windowsip/website' --opt o='username=*****,password=*****' website
docker run -v website:/var/www/html
I know it is an old thread but just I had the same problem, hope it helps to others
Okey Okey I didn't read the last part of the question. Yes, you need to poke holes in the firewall. But still is useful, I have a linux server with docker and I use it via VPN when I work from home in my laptop. The container has local access to everything.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Nakilon |