简体   繁体   中英

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

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, ie :

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM