sqlpetr icon indicating copy to clipboard operation
sqlpetr copied to clipboard

Error building Adventureworks docker image and connecting to postgres

Open larissawn opened this issue 5 years ago • 9 comments

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?

larissawn avatar Mar 05 '20 06:03 larissawn

I'm on a Mac machine. sqlpetr is up to date.

larissawn avatar Mar 05 '20 06:03 larissawn

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?

znmeb avatar Mar 05 '20 16:03 znmeb

It looks like a port issue to me.

smithjd avatar Mar 05 '20 18:03 smithjd

5432 vs 5439??

znmeb avatar Mar 05 '20 22:03 znmeb

I saw this Saturday building the book but haven't had a chance to troubleshoot it.

znmeb avatar Mar 05 '20 22:03 znmeb

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.

smithjd avatar Mar 05 '20 23:03 smithjd

docker --version returns this : Docker version 19.03.5, build 633a0ea

larissawn avatar Mar 06 '20 01:03 larissawn

That version and build is exactly what I get on my machine.

smithjd avatar Mar 06 '20 16:03 smithjd

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.

znmeb avatar Mar 06 '20 22:03 znmeb