Support Questions

Find answers, ask questions, and share your expertise

way mount folder inside container to local/host

avatar
Rising Star

hi all,

in general, it is very easy to mount folders from local/host to container

 

Any suggestions to mount folder inside container to local/host like

-v  /path_folder_in_container/:/path_folder_in_local/

or 

-v  /path_folder_in_container/:/path_folder_in_host/

 

 

Many thanks

2 REPLIES 2

avatar
Master Guru

@thuylevn I found this somewhere you can try this.

 

You could do this using the docker-machine mount command.

Using this command,you can mount directories from a machine to your local host, using sshfs.

The notation is machinename:/path/to/dir for the argument; you can also supply an alternative mount point (default is the same dir path).

consider an example:

$ mkdir foo
$ docker-machine ssh dev mkdir foo
$ docker-machine mount dev:/home/docker/foo foo
$ touch foo/bar
$ docker-machine ssh dev ls foo
bar

Now you can use the directory on the machine, for mounting into containers. Any changes done in the local directory, is reflected in the machine too.

$ eval $(docker-machine env dev)
$ docker run -v /home/docker/foo:/tmp/foo busybox ls /tmp/foo
bar
$ touch foo/baz
$ docker run -v /home/docker/foo:/tmp/foo busybox ls /tmp/foo
bar
baz

The files are actually being transferred using sftp (over an ssh connection).


Cheers!
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.

avatar
Rising Star

Hi @GangWar ,

Thanks for your sharing, how ever I tried with image  

 

apache/nifi:latest https://hub.docker.com/r/apache/nifi/
My expectation is mount folder /opt/nifi/nifi-current/conf (inside nifi-container) to folder nifi (in docker-machine). However it doesnot work.

 

Do you have any suggestions?