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

时间:2017-07-14 21:52:02

标签: postgresql haskell docker

我正在尝试使用Docker构建和运行Haskell项目。项目包含PSQL数据库。 当我编写run-command 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

1 个答案:

答案 0 :(得分:2)

  

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

这告诉你,在容器内的localhost上,没有运行postgres。

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