Docker: Permission denied on folders added with ADD

I'm trying to configure a postgresql installation using docker.

FROM ubuntu:13.10

ADD . /db

# install postgres
# ...

RUN chown postgres:postgres /db -R && \
    chmod 700 /db -R

USER postgres
RUN /etc/init.d/postgresql start &&\
    createdb test &&\
    psql -d test -f /db/all.sql

I can access to the folder /db, but not to /db/plpgsql (which contains files executed by /db/all.sql)

I tried chmod 777 on /db/plpgsql but it does not work either, permission is denied.

postgres@c364bdd94652:/$ ls -l | grep db
drwxrwxrwx   5 postgres postgres 4096 Jul 10 17:39 db
postgres@c364bdd94652:/$ cd db/
postgres@c364bdd94652:/db$ ls -l
-rwxrwxrwx  1 postgres postgres   2567 Jul 10 16:34 Dockerfile
-rwxrwxrwx  1 postgres postgres    358 Jul 10 14:53 all.sql
-rwxrwxrwx  1 postgres postgres    642 Jul 10 15:35 init.sql
drwxrwxrwx 10 postgres postgres   4096 Jul 10 16:36 plpgsql
postgres@c364bdd94652:/db$ cd plpgsql/
bash: cd: plpgsql/: Permission denied

How do I access to that folder ?


Solution 1:

While there was some resolution in the commented issue, it seems like this may be related to a problem with AUFS.

If your docker info reports your aufs driver is missing dirperm1 support:

Storage Driver: aufs
  Root Dir: /var/lib/docker/aufs 
  Backing Filesystem: extfs
  Dirs: 148
  Dirperm1 Supported: false

...then you might need to update the aufs on your host, or try using a different storage driver. Somewhat frustrating to run into this with aufs as the default storage driver, when changing permissions is something you'd just kind of expect to work correctly.