Server terminated abnormally before or while processing the request. Server closed the connection unexpectedly On host "127.0.0.1" and accepting TCP/IP connections on port 5432? With Docker network in BRIDGE mode docker run -i -add-host=dockerhost:`docker-machine ip $` -e POSTGRES_URI=postgresql://dockerhost:5432/db -p 8000:8000 -p 5432:5432 my/image With Docker network in HOST mode docker run -i -net=host -h 127.0.0.1 -e POSTGRES_URI=postgresql://127.0.0.1:5432/db my/imageĬould not connect to server: Connection refused Docker container OS: python:3.6.0-alpine I made a game server in Python that connects to a PostgreSQL db using psycopg2. In order to connect to a PostgreSQL database instance from your Python script, you need to use a database connector library.With the use of psycopg2-binary, I think, you can easily achieve what you want. You first cross the (1)- (2) gap with SSH then you cross the (2)- (3) with the command sudo docker-compose exec postgres bash. Now, what you described in the question is this. So you can write bare python service to interact with a PostgreSQL server. Between (2) and (3) you have docker networking. I am not sure if it is related to the Postgres connection settings or to the Docker network settings. I realize that your target is just to establish a connection with your PostgreSQL server and interact with your DB.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |