无法在OS X上使用Docker构buildHaskell / Postgres项目

我正在尝试使用Docker来构build和运行Haskell项目。 项目包含PSQL数据库。 当我编写运行命令docker run project_name /usr/local/bin/project_name ,所以我得到:

  $ docker run carma-bundle /usr/local/bin/carma no port specified, defaulting to port 8000 carma: Initializer threw an exception... libpq: failed (could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432? could not connect to server: Cannot assign requested address Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? ) ...but before it died it generated the following output: Initializing app @ / Initializing heist @ /heist ...loaded 0 templates from /srv/snaplets/heist ...adding 1 templates from resources/static/tpl with route prefix // Initializing CookieSession @ /session Initializing postgresql-simple @ /db Initializing postgresql-auth @ /auth ...setting up filesystem 

附加信息:

 $ docker --version Docker version 17.06.0-ce, build 02c1d87 $ psql --version psql (PostgreSQL) 9.3.16 $ stack --numeric-version 1.4.0 

服务器是否在主机“localhost”(127.0.0.1)上运行并接受
端口5432上的TCP / IP连接?

这是告诉你,在本地主机,在你的容器内,没有postgres运行。

每个容器都有自己的本地主机地址。 它们与其他容器中的本地主机是分离的,并与运行Docker的主系统上的本地主机地址分离。