3

I use docker run -it -v $PWD/website:/var/www/html/website gerbawn/nginx /bin/bash to start a docker container. But I can't use ls to look /var/www/html/website directory.

image

I had change directory permission to 777 but no use.

Community
  • 1
  • 1
GerBawn
  • 301
  • 1
  • 4
  • 13
  • Would http://stackoverflow.com/questions/24288616/permission-denied-on-accessing-host-directory-in-docker help? Or http://stackoverflow.com/a/30101747/6309? – VonC Aug 18 '15 at 08:28
  • Thanks, I get the answer.It because selinux – GerBawn Aug 18 '15 at 08:41

1 Answers1

2

The first link I mentioned "Permission denied on accessing host directory in docker" seems to be the root cause:
Assign the proper SELinux policy type to the host directory

chcon -Rt svirt_sandbox_file_t host_dir

(host_dir is a path to the directory on host system that is mounted to the container.)

Actually, since docker 1.7, you should be able to do a:

docker run -it -v $PWD/website:/var/www/html/website:z gerbawn/nginx /bin/bash
                                                    ^^
# or:
docker run -it -v $PWD/website:/var/www/html/website:Z gerbawn/nginx /bin/bash
                                                    ^^
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250