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

3.7k views Asked by At

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.

1

There are 1 answers

3
Rob H On

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)