Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mac和mkdir许可的Docker_Docker_Docker Compose_Dockerfile_Docker For Mac_Postgis Installation - Fatal编程技术网

Mac和mkdir许可的Docker

Mac和mkdir许可的Docker,docker,docker-compose,dockerfile,docker-for-mac,postgis-installation,Docker,Docker Compose,Dockerfile,Docker For Mac,Postgis Installation,使用mac应用程序的docker。昨天刚安装好所有东西。终于让应用程序运行起来了。 但在安装postgis之前,我无法运行迁移。所以我放弃了官方博士后dockerhub的图片。但是,当docker试图为pg_数据卷设置mkdir时,我不断遇到权限被拒绝的问题 Dockerfile: version: '3' # Containers we are going to run services: # Our Phoenix container

使用mac应用程序的docker。昨天刚安装好所有东西。终于让应用程序运行起来了。 但在安装postgis之前,我无法运行迁移。所以我放弃了官方博士后dockerhub的图片。但是,当docker试图为pg_数据卷设置mkdir时,我不断遇到权限被拒绝的问题

Dockerfile:

        version: '3'

    # Containers we are going to run
    services:
      # Our Phoenix container
      phoenix:
        # The build parameters for this container.
        build:
          # Here we define that it should build from the current directory
          context: .
        environment:
          # Variables to connect to our Postgres server
          PGUSER: postgres
          PGPASSWORD: postgres
          PGDATABASE: gametime_dev
          PGPORT: 5432
          # Hostname of our Postgres container
          PGHOST: db
        ports:
          # Mapping the port to make the Phoenix app accessible outside of the container
          - "4000:4000"
        depends_on:
          # The db container needs to be started before we start this container
          - db
          - redis

      redis:
        image: "redis:alpine"
        ports:
          - "6379:6379"
        sysctls:
          net.core.somaxconn: 1024

      db:
        # We use the predefined Postgres image
        image: mdillon/postgis:11-alpine
        environment:
          # Set user/password for Postgres
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          # Set a path where Postgres should store the data
          PGDATA: /var/lib/postgresql/data/pgdata
        restart: always
        volumes:
          - pgdata:/usr/local/var/postgres_data
    # Define the volumes
    volumes:
      pgdata:
我得到的错误是:

db_1       | mkdir: can't create directory '/var/lib/postgresql/data/pgdata': Permission denied
但在使用postgres(官方)图像时不会发生这种情况。我在谷歌上到处搜索。我确实读过一些关于Docker for Mac在它作为当前用户的localhost用户而不是root用户在VM中创建的容器上运行命令的内容。但这对我来说毫无意义——如果是这样的话,我该如何应对呢

[额外说明:]-我确实尝试了:z和:z-仍然得到了与上面完全相同的错误


提前感谢时间。

您的
db
服务状态的环境变量,PGDATA处于
/var/lib/postgresql/data/PGDATA
但您正在
/usr/local/var/postgres\u data
的容器中装入PGDATA卷

我的猜测是,当postgres启动时,它正在查看env变量,并期望在
/var/lib/postgresql/data/pgdata
中有一个dir。由于它可能不存在,它正试图将其创建为postgres用户,而postgres用户无权这样做


对两个VAR使用相同的路径,我确信它将修复错误。

我认为@Zeitounator是正确的,但如果您可以为图像mdillon/postgis:11发布Dockerfile,那么我们将肯定知道,因为这是容器内部的问题,与Mac Docker无关。