Rex-ray AWS S3 external volume docker (docker-compose not working)

1.2k views Asked by At

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 protected]
      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
1

There are 1 answers

0
marcorel On

In the entrypoint script PGDATA directory try to be changed to user postgres.

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

It also try to change access rights :

chmod 700 "$PGDATA" || :

As it is not possible to change the owner of the volume bridging point, Add the following environment variable in postgres's service definition :

PGDATA: "/var/lib/postgresql/data/pgdata"