![]() I find that after doing a fresh install of docker following the info here ( ) then re-running the sudo apt-get install command for the docker packages, I was able to psql into the container's DB, but only for the first time of running that container. but nothing about the rejected connections from the multiple attempts I try since the time of that last logged message.Īnyone have any ideas what could be going on here? Any debugging suggestions? 03:59:12.982 UTC LOG: database system is ready to accept connections 03:59:12.971 UTC LOG: database system was shut down at 03:59:12 UTC PostgreSQL init process complete ready for start up. The last thing that the container logs just shows that the DB is ready to accept connections This is also the only docker container I have running and the image was just downloaded today:ĬONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESĤ7c77203991c postgres:13 "docker-entrypoint.s…" 25 minutes ago Up 25 minutes 0.0.0.0:5432->5432/tcp, :::5432->5432/tcp sleepy_chandrasekhar Unit rvice could not be found.Īnd this is the only thing that appears to be using the specified port (for both IPv4 and IPv6):ĭocker-pr 29152 root 4u IPv4 6892807 0t0 TCP *:5432 (LISTEN)ĭocker-pr 29164 root 4u IPv6 6890891 0t0 TCP *:5432 (LISTEN) Or usingpgadmin4` from my local desktop or changing "localhost" to the value "0.0.0.0" ![]() This probably means the server terminated abnormally Psql: connection to server at "localhost" (127.0.0.1), port 5432 failed: server closed the connection unexpectedly OperationalError: (psycopg2.OperationalError) connection to server at "localhost" (127.0.0.1), port 5432 failed: server closed the connection unexpectedlyĮngine = also can't connect when using psql You will stop and remove your current container and create a new one.Creating postgres docker container (w/ the most recent version of docker) in Ubuntu 18.04 like.ĭocker run -it -e POSTGRES_USER="root" -e POSTGRES_PASSWORD="root" -e POSTGRES_DB="ny_taxi" -v /my/absolute/path/to/my/local/folder/ny_taxi_postgres_data:/var/lib/postgresql/data:rw -p 5432:5432 postgres:13 The solution store the database outside of the container docker volume create my-postgres-db-db ![]() The problem, We stop and start the container with the command “ docker stop my-postgres-db” and “ docker start my-postgres-db” when creating a new container will not allow us to access the database that you are created, as it was isolated in your container.Ĭreate a new volume with the following command. The output terminal as below Docker Manage data persistence I will run a command to query the table created. ![]() I will create a table as an example CREATE TABLE sites (id SERIAL PRIMARY KEY, name VARCHAR(100)) Using psql command to connect the database psql -host localhost -port 5432 -username devopsroles -dbname my-db
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |