2017-07-14 65 views
1

我试图用Docker构建并运行Haskell项目。项目包含PSQL数据库。 当我写的运行命令docker run project_name /usr/local/bin/project_name,所以我得到:无法在OS X上使用Docker构建Haskell/Postgres项目

$ 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 

回答

2

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

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

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