Connecting to Postgresql in a docker container from outside

后端 未结 14 1996
太阳男子
太阳男子 2020-11-29 14:42

I have Postgresql on a server in a docker container. How can I connect to it from the outside, that is, from my local computer? What setting should I apply to allow that?

14条回答
  •  臣服心动
    2020-11-29 15:16

    I know this is late, if you used docker-compose like @Martin

    These are the snippets that helped me connect to psql inside the container

    docker-compose run db bash

    root@de96f9358b70:/# psql -h db -U root -d postgres_db

    I cannot comment because I don't have 50 reputation. So hope this helps.

提交回复
热议问题