简体   繁体   中英

Docker Container Mount Folder

I am trying to mount my VM Machine folder to Container using below command

sudo docker run -d -it  --name devtest \
-v /home/minhaj/GOQTINDOOR:/home/user:Z  therecipe/qt:linux bash

But do not see any folder on my Container home/user. Please advise what is wrong in my command or do I need to execute more commands to mount folder on Container.

Your issue is that you are running the container in detached mode. Remove -d

sudo docker run -it --name devtest -v /home/minhaj/GOQTINDOOR:/home/user therecipe/qt:linux bash​

After this if you compile something inside the container and copy it is inside the /home/user folder it will be automatically available inside /home/minhaj/GOQTINDOOR . You can copy and delete any file inside /home/minhaj/GOQTINDOOR . But you can't delete the /home/minhaj/GOQTINDOOR folder itself as it the mount point.

Any files or folder inside /home/minhaj/GOQTINDOOR can be deleted from inside the container by delete them from /home/user folder.

docker cp command is only required if you want to copy a file which is not there in any mounted path.

For that you can use

docker cp <containerid>:<pathinsidecontainer> <pathonhost>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM