简体   繁体   中英

How to access a directory in hosts machine from inside a docker container?

I'm using docker version Docker version 1.9.1, build a34a1d5 on ubuntu:14.04 . I have created a docker container with a volume option like this docker run -it -p 80:8080 -v host/folder:container/folder ubuntu:14.04 /bin/bash . host/folder has some files that i'm trying to access from container/folder . The files from host/folder isnt available from container/folder .

when you mount a host folder as a volume with -v you must specify absolute paths, so replace host/folder and container/folder with the absolute path.

Something like docker run -it -p 80:8080 -v /home/uday/host/folder:/container/folder ubuntu:14.04 /bin/bash (of course set the correct path to your host/folder directory)

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