Ziv
Ziv

Reputation: 85

Docker-Compose not creating schema from local db while building docker image

I have created a docker-compose file with 2 services web and POSTGRES. When I run the below docker-compose file, it does not create tables that is in my local POSTGRES db. I have provided the environment variables to use. I think it should use these variables and grab the schema and creates the schema in docker right? When I call the rest API, I am getting relation "x" does not exist.

version: "3"
services:
  web:
    build: .
    depends_on:
      - postgres
    ports:
      - "8000:8000"
    volumes:
      - postgres-db:/var/lib/postgresql/data
    environment:
      - DATABASE_HOSTNAME=postgres
      - DATABASE_PORT=5432
      - DATABASE_PASSWORD=password!
      - DATABASE_NAME=dump
      - DATABASE_USERNAME=postgres
      - SECRET_KEY=021158d8d8d8d8d8d8d8d87
      - ALGORITHM=HS256
      - ACCESS_TOKEN_EXPIRE_MINUTES=50
  postgres:
    image: postgres
    environment:
      - POSTGRES_PASSWORD=password!
      - POSTGRES_DB=dump
volumes:
  postgres-db: {}

Upvotes: 0

Views: 567

Answers (0)

Related Questions