Docker container for Postgres 9.1 not exposing port 5432 to host

前端 未结 7 1426
醉酒成梦
醉酒成梦 2020-12-23 20:18

I\'m trying to use a Docker container to run a PostgreSQL server, and connect with it from my host machine.

My configuration is:

  • Host machine: Mac OS X
7条回答
  •  囚心锁ツ
    2020-12-23 20:34

    Your docker host is a virtual machine, which has it's own IP affffdres. You can detect this IP address by entering the following command:

    docker-machine ip
    

    The answer will be something like 192.168.99.100

    When you have mapped the ports using the -p 5432:5432 switch, you will be able to connect to postgres with any tool from your dev machine using the IP address mentioned.

提交回复
热议问题