Jose Cabrera Zuniga
Jose Cabrera Zuniga

Reputation: 2627

Sharing a subfolder of my home folder with Docker run

The command

echo ~

produces in my box:

bash: /home/jcabrerazuniga: Is a directory

I want to share the folder:

echo ~ + '/myPrograms' (= /home/jcabrerazuniga/myPrograms ) with an internal folder in a docker container as with:

docker run --name=dev_server --network=host --privileged \      
      -v `echo ~` + '/mypograms':/home/${USER} \  
      -it jcabrerazuniga/mycontainer:v1 /bin/bash

Is this possible? how?

Upvotes: 1

Views: 88

Answers (1)

atline
atline

Reputation: 31664

See this:

$HOME is a Linux bash shell variable. It indicates the home directory of the current user

So, for you, you just need to use something like next:

docker run -v ${HOME}/mypograms:/home/${USER} -it ubuntu:16.04 /bin/bash

Upvotes: 1

Related Questions