Coder Social home page Coder Social logo

Comments (6)

renzok avatar renzok commented on August 28, 2024 1

Another variant to the recommended version of @yosifkit

sudo docker run --name pt -t -p 0.0.0.0:5555:5432 -d postgres

to expose the container internal port 5432 to port 5555 on your host machine.

from postgres.

Starefossen avatar Starefossen commented on August 28, 2024

Could you attach the logs from your pgadmin and postgres containers? docker logs [id | name]

from postgres.

brizjin avatar brizjin commented on August 28, 2024

postgres logs:

2015-08-02 14:44:16 MSK LOG: database system was shut down at 2015-08-02 02:16:41 MSK
2015-08-02 14:44:16 MSK LOG: MultiXact member wraparound protections are now enabled
2015-08-02 14:44:16 MSK LOG: autovacuum launcher started
2015-08-02 14:44:16 MSK LOG: database system is ready to accept connections
2015-08-02 14:44:16 MSK LOG: incomplete startup packet

pgadmin:

2015-08-02 14:46:47 STATUS : Соединение с базой данных...
2015-08-02 14:46:47 INFO : Opening connection with connection string: host='localhost' dbname='postgres' user='postgres' password='XXXXXX' port=5432 application_name='pgAdmin III - Браузер'
2015-08-02 14:46:49 STATUS : Соединение с базой данных... (2,02 секунд)
2015-08-02 14:46:49 ERROR : Error connecting to the server: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.

docker logs:

ivan@ivan-VirtualBox:/var/log/postgresql$ docker logs pg
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /var/lib/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

postgres -D /var/lib/postgresql/data

or
pg_ctl -D /var/lib/postgresql/data -l logfile start

FATAL: the database system is starting up
LOG: database system was shut down at 2015-08-02 11:45:57 UTC
PostgreSQL init process in progress...
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
ALTER ROLE

/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
LOG: shutting down
LOG: database system is shut down

PostgreSQL init process complete; ready for start up.

LOG: database system was shut down at 2015-08-02 11:45:59 UTC
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started

from postgres.

yosifkit avatar yosifkit commented on August 28, 2024

It looks like your pgadmin is trying to connect to localhost, if that is being run in a container you will need to tell it to connect to the IP address of the postgres container. Here is how I connect with psql in a separate container:

docker run -it --rm --link some-postgres:postgres postgres psql -h postgres -U postgres
# can use the host "postgres" since container links will populate /etc/hosts

What are the docker run lines that you are doing?

from postgres.

brizjin avatar brizjin commented on August 28, 2024

renzok, your advice is helped. i did change port to 5555 and pgadmin start connect to database. thank you!

from postgres.

renzok avatar renzok commented on August 28, 2024

good to hear :) I guess then that this issue is then good to be closed.

from postgres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.