On May 25, 2019, at 19:32, Kevin Burkett <
stlb...@gmail.com> wrote:
> a bit more info, just to show the ip and port are active:
>
> $ docker ps
> CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
> 567799de6e98 postgres:10-alpine "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:5432->5432/tcp postgresqldb
>
> $ sqitch deploy --target db:pg://
postgres:12...@0.0.0.0/phile_starter --plan-file sqitch.plan
> could not connect to server: Connection refused
> Is the server running on host "0.0.0.0" and accepting
> TCP/IP connections on port 5432?
Odd. Here’s what I get on macOS:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d7b768710c49 postgres:10-alpine "docker-entrypoint.s…" 9 minutes ago Up 9 minutes 0.0.0.0:5432->5432/tcp serene_hertz
$ curl -L
https://git.io/fAX6Z -o sqitch && chmod +x sqitch
$ ./sqitch status db:pg://postgres:1234@localhost/postgres
# On database db:pg://postgres:@localhost/postgres
Database db:pg://postgres:@localhost/postgres has not been initialized for Sqitch
Which means it connected and found that the database isn’t initialized. Deploy works, too, so both the Sqitch database connection and the execution of psql work:
$ ./sqitch deploy db:pg://
postgres:12...@0.0.0.0/postgres
Adding registry tables to db:pg://
postgres:@0.0.0.0/postgres
Deploying changes to db:pg://
postgres:@0.0.0.0/postgres
+ foo ..... ok
+ blah .... ok
+ sup ..... ok
+ blargh .. ok
+ yipee ... ok
Are you on macOS? I don’t have quick access to a Linux instance to test (long story), but it’s possible that the Sqitch container doesn’t have direct access to port 5432 on the Docker host, or maybe can’t route through the docker host to the Postgres container. Another thing to try is to explicitly tell the Sqitch container to link to the Postgres container’s network. Since your Postgres container is named postgresqldb, you can link by adding this to the docker-sqitch.sh script:
--link postgresqldb:pg
Then use the host name “pg” instead of 0.0.0.0.
If that works, then great. Mystery to me as to why. But I learned when I went to look up the docs just now that --link is deprecated! Kind of annoying.
https://docs.docker.com/network/links/
Time to learn something new, I guess.
HTH,
David