Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

way mount folder inside container to local/host

Highlighted

way mount folder inside container to local/host

Explorer

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

Re: way mount folder inside container to local/host

Expert Contributor

@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).

Highlighted

Re: way mount folder inside container to local/host

Explorer

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?

Don't have an account?
Coming from Hortonworks? Activate your account here