0

I'm using Django with Postgres database so I've created separate docker containers for Django and Postgres, now I want to share the dump file with my team but I'm unable to access the dump file, please let me know how can I access the dump file and after accessing it how can we import it using the container?

docker-compose.yml

version: "3.8"
   
services:
  pgdb:
    image: "postgres"
    restart: always
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    ports:
      - "5432:5432"

location inside db docker container

enter image description here

Zain Khan
  • 1,644
  • 5
  • 31
  • 67
  • Possible duplicate of https://stackoverflow.com/questions/24718706/backup-restore-a-dockerized-postgresql-database – iklinac Dec 23 '21 at 13:48

1 Answers1

1

You can access it using docker cp utility

docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-

But rather than doing that you can directly pipe output of pg_dump

docker exec -t container pg_dump ... > dump.sql

and import

cat dump.sql | docker exec -i container psql ...
iklinac
  • 14,944
  • 4
  • 28
  • 30