Error building Adventureworks docker image and connecting to postgres
I get an error when building a docker image. Because of the error, I also cannot connect to PostgreSQL.
Code:
source(here("book-src", "restore-adventureworks-postgres-on-docker.R"))
Error:
Error response from daemon: Container 34a50e47793b02a0259fa8f533b6078dadb546f165dbd0987d6d8f22ba30d2ce is not running
Error response from daemon: Container 34a50e47793b02a0259fa8f533b6078dadb546f165dbd0987d6d8f22ba30d2ce is not running
When I try to connect:
Sys.sleep(sleep_default)
# con <- connection_open( # use in an interactive session
con <- dbConnect( # use in other settings
RPostgres::Postgres(),
# without the previous and next lines, some functions fail with bigint data
# so change int64 to integer
bigint = "integer",
host = "localhost",
port = 5439, # this version still using 5432!!!
user = "postgres",
password = "postgres",
dbname = "adventureworks"
)
I get this error:
Error: 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 5439?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5439?
I'm on a Mac machine. sqlpetr is up to date.
I saw something like this a week ago on Linux - I'll take a look at it today and see what's going on. Can you do a docker --version from a terminal and post the result here?
It looks like a port issue to me.
5432 vs 5439??
I saw this Saturday building the book but haven't had a chance to troubleshoot it.
Yes, the package was using port 5439, but there seemed to be problems with it (that I'm not clear about at the moment). so when I reverted to using connection_open() I went back to the default port: 5432.
docker --version returns this : Docker version 19.03.5, build 633a0ea
That version and build is exactly what I get on my machine.
Yes, the package was using port 5439, but there seemed to be problems with it (that I'm not clear about at the moment). so when I reverted to using
connection_open()I went back to the default port: 5432.
The port being listened to in the container has to be the same as what the connect operation is connecting to.