Can i mount a directory from local machine to a container which is running on a virtual machine?

I have source code existing on my local machine. i want to mount it to a container which is running on a virtual machine. The container uses phoenix framework image.
docker run --name elixirphoenix -it -v ~/path/to/HelloWorld:/app/code -p 4000:4000 sharathkumar3011/docker-phoenix
~/path/to/HelloWorld is the path to sorce code on my local machine.
The above command executes successfully when i run it on local machine. But when i try to run on my virtualmachine it does not mount the HelloWorld directory to /app/code in my container.

Please can anybody guide me?

Copy the source code directory to the virtual machine. Alternatively, create a shared directory between the local machine and the virtual machine. Which virtualization software is used? For VirtualBox refer

1 Like