我正在尝试用Docker构建和运行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发布于 2017-07-15 06:23:48
是在主机"localhost“(127.0.0.1)上运行的服务器,它接受
端口5432上的TCP/IP连接?
这告诉您,在本地主机上,在您的容器中,没有postgres在运行。
每个容器都有自己的本地主机地址。它们与其他容器中的localhost是分开的,并且与运行Docker的主系统上的localhost地址是分开的。
https://stackoverflow.com/questions/45112096
复制相似问题