V
V
VitaliySm2020-02-23 19:58:26
PostgreSQL
VitaliySm, 2020-02-23 19:58:26

How to connect to a postgres container from another server?

the container with postgres is spinning on the same server with the following compos file:

version: "2"
services:
    db:
        image: "postgres:11-alpine"
        container_name: db
        restart: always
        ports:
            - 127.0.0.1:${POSTGRES_PORT}:5432
        environment:
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
            - POSTGRES_USER=${POSTGRES_USER}
        volumes:
            - postgres-volume:/var/lib/postgresql/data

volumes:
    postgres-volume:

How can I connect to this database from another server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-02-23
@VitaliySm

Change the port directives so that the container is not bound to the localhost, but to the external

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question