加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

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

发布时间:2020-12-13 17:19:37 所属栏目:Linux 来源:网络整理
导读:我正在尝试使用docker配置 postgresql安装. FROM ubuntu:13.10ADD . /db# install postgres# ...RUN chown postgres:postgres /db -R chmod 700 /db -RUSER postgresRUN /etc/init.d/postgresql start createdb test psql -d test -f /db/all.sql 我可
我正在尝试使用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作为默认存储驱动程序遇到这种情况有点令人沮丧,在更改权限时,您可能希望正常工作.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读