R
R
Roman Rakzin2020-10-16 14:19:09
Docker
Roman Rakzin, 2020-10-16 14:19:09

How to set up a Docker-compose file for a database?

I am new to Docker. Tell me how I can set it up so that PostgreSQL in docker has its own volume on the physical disk for the database, so that the data is not reset when rebooting. And how to write the paths if my computer is on Windows and the path to the database is, say, C:\myPath\Pstgres\Data\ , and the server is on linux, and there the database will be, say, in var\lib\postgres\data ?
And at the same time, so that I could log in from a third-party IDE and see the database. Those. so that it was not a completely internal closed network, as far as I understand. How to write a docker-compose file for such a task?
Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
korsar182, 2020-10-16
@korsar182

version: "3.8"

services:
  db:
    restart: unless-stopped
    image: postgres:10.13-alpine
    environment:
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    volumes:
      - 'db-data:/var/lib/postgresql/data'
    ports:
      - 5432:5432

volumes:
  db-data:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question