GerBawn
GerBawn

Reputation: 301

docker: Can't use ls in mount directory

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.

Upvotes: 3

Views: 1756

Answers (1)

VonC
VonC

Reputation: 1323115

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
                                                    ^^

Upvotes: 2

Related Questions