W
W
Wayne12121212021-05-25 01:17:03
PostgreSQL
Wayne1212121, 2021-05-25 01:17:03

How to force docker postgres to watch the database locally, and not from the container?

Hello!
I run docker-compose and the database is without tables. How to make reading and changing data from a local database, where everything is?

version: "3"
services:
    db:
      image: postgres:latest
      environment:
        POSTGRES_USER: admin
        POSTGRES_PASSWORD: admin
        POSTGRES_DB: docker
      volumes:
        - ./db:/var/lib/pgsql/data //слева лежит реальная база, нужно ли так?
      ports:
        - "5432:5432"
      restart: always
    server:
      image: node:latest
      command: sh -c "npm install && npm run dev"
      volumes:
        - ./backend:/usr/src/client
      working_dir: /usr/src/client
      ports:
        - "9001:9001"
      restart: always
      tty: true
      links: 
        - db


I would be very grateful for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-05-25
@q2digger

if you have a local database, why are you deploying a container with postgress? let the base on the host spin, refer to it from the application container at its host address.
and just remove the db part from docker-compose

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question