DEV Community

Umesh Kumar Dhakar
Umesh Kumar Dhakar

Posted on

Share file between Host System and Docker Container.

1. Create a folder in Host System.
C:\\<directory-name>
(eg. C:\\Tunnel)

2. Add this folder in Shared Folder list of VM.
Go to : Machine > Settings > Shared Folder
(Add folder here.)

3. Create folder in VM.
mkdir /<directory-name>
(eg. mkdir /vm_tunnel)

4. Mount Shared Folder in VM directory.
mount -t vboxsf <host-directory-name> /<vm-directory-name>
(eg. mount -t vboxsf Tunnel /vm_tunnel)

5. Test sharing by creating file in Tunnel or /vm_tunnel and check in
/vm_tunnel or Tunnel.

6. Share file between Host and Conatiner.
docker cp <container>:/path/to/file/in/container /path/of/vm-direcory/where/host-folder/is/mounted
(eg. docker cp foo:/data/bar.txt /vm_tunnel/)

Thanks for reading! ๐Ÿ˜Š

Top comments (0)