Home > database >  Access sql dump inside docker container django postgres
Access sql dump inside docker container django postgres

Time:12-24

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

CodePudding user response:

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 ...
  • Related