1

When starting redis container with the following configuration:

redis:
  image: redis
  ports:
    - "6379:6379"
  volumes:
    - "/data:/data"
  deploy:
    placement:
      constraints: [node.role == manager]
  command: redis-server --appendonly yes
  networks:
    - webnet

I get the following error in logs:

chown: cannot read directory '.': Permission denied
  • Docker host is a Red Hat Enterprise Linux Server release 7.4 (Maipo)
  • /Data exists on host
  • Tried to chmod 777 /Data
  • Tried chown 999:999 /Data
Julien Nury
  • 297
  • 2
  • 14

1 Answers1

3

Finally I figured out that it was related to seLinux on host.

The following command allowed the container to start (but disabled seLinux):

su -c "setenforce 0"

And the following one fixed the problem for good:

chcon -Rt svirt_sandbox_file_t /data

Then I was able to enable seLinux again with:

su -c "setenforce 1"

I found the solution in this post: Permission denied on accessing host directory in docker

Julien Nury
  • 297
  • 2
  • 14