linux – Docker:使用ADD添加的文件夹上的权限被拒绝

我正在尝试使用docker配置 postgresql安装.
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

我可以访问文件夹/ db,但不能访问/ db / plpgsql(包含/db/all.sql执行的文件)

我在/ db / plpgsql上尝试了chmod 777,但它也不起作用,权限被拒绝.

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

我如何访问该文件夹?

解决方法

虽然在 commented issue中有一些解决方案,但似乎这可能与 a problem with AUFS有关.

如果您的docker info报告您的aufs驱动程序缺少dirperm1支持:

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

…然后您可能需要更新主机上的aufs,或尝试使用其他存储驱动程序.使用aufs作为默认存储驱动程序遇到这种情况有点令人沮丧,在更改权限时,您可能希望正常工作.

相关文章

文章浏览阅读1.8k次,点赞63次,收藏54次。Linux下的目录权限...
文章浏览阅读1.6k次,点赞44次,收藏38次。关于Qt的安装、Wi...
本文介绍了使用shell脚本编写一个 Hello
文章浏览阅读1.5k次,点赞37次,收藏43次。【Linux】初识Lin...
文章浏览阅读3k次,点赞34次,收藏156次。Linux超详细笔记,...
文章浏览阅读6.8k次,点赞109次,收藏114次。【Linux】 Open...