1

I am trying to use postgres and pgadmin with rex-ray external volume on AWS S3. I did:

Docker plugin install rexray/s3fs:0.11.4 S3FS_ACCESSKEY=XXXXXXXXXXXXX S3FS_SECRETKEY=XXXXXXXXXXXXXXXXX

And then I created two volumes (for postgres and pgadmin):

Docker volume create --driver rexray/s3fs:0.11.4 myrexvol1-1234
Docker volume create --driver rexray/s3fs:0.11.4 myrexvol2-1234

And I can see the volumes when I run docker volume ls.

I now try to use those external S3 volumes in docker-compose but it does not work and nothing is created in S3:

version: "3.8"
services:
  pgAdmin:
    restart: always
    container_name: pgadmincontainer
    image: dpage/pgadmin4:4.25
    ports:
      - "8000:80"
    environment:
      PGADMIN_DEFAULT_EMAIL: email@admin.com
      PGADMIN_DEFAULT_PASSWORD: 1234
    volumes:
      - myrexvol1-1234:/var/lib/pgadmin
  postgres:
    image: postgres
    container_name: databasecontainer
    restart: always
    environment:
      POSTGRES_USER: me
      POSTGRES_PASSWORD: password
      POSTGRES_DB: database
    ports:
      - 5432:5432
    volumes:
      - ./sqlscripts:/docker-entrypoint-initdb.d
      - myrexvol2-1234:/var/lib/postgresql/data
volumes:
  myrexvol1-1234:
    name: myrexvol1-1234
    external: true
  myrexvol2-1234:
    name: myrexvol2-1234
    external: true

What am I doing wrong? Strangely, I can manually create something inside container and it is then reflected inside S3 bucket, i.e. :

docker container run -it -v myrexvol2-1234:/myvol centos
  ...inside the container here...
# cd /myvol
# date >mydate
# ls -l
4

1 回答 1

0

在入口点脚本 PGDATA 目录中尝试更改为用户 postgres。

find "$PGDATA" \! -user postgres -exec chown postgres '{}' +

它还尝试更改访问权限:

chmod 700 "$PGDATA" || :

由于无法更改卷桥接点的所有者,请在 postgres 的服务定义中添加以下环境变量:

PGDATA: "/var/lib/postgresql/data/pgdata"
于 2021-10-21T08:22:00.387 回答