Tôi đang chơi xung quanh với Docker và tôi muốn Dockerize một container Postgres.Dockerizing PostgreSQL - psql kết nối từ chối
tôi sau khi chính thức example nhưng tôi không thể kết nối với các hình ảnh chạy bằng psql.
tôi tạo ra các Dockerfile với nội dung của ví dụ. Tôi đã xây dựng một hình ảnh từ Dockerfile và gán cho nó một cái tên. Sau đó, tôi chạy container máy chủ PostgreSQL (trong nền trước).
~/test » docker run --rm -P --name pg_test eg_postgresql
2014-10-10 06:12:43 UTC LOG: database system was interrupted; last known up at 2014-10-10 06:12:29 UTC
2014-10-10 06:12:43 UTC LOG: database system was not properly shut down; automatic recovery in progress
2014-10-10 06:12:43 UTC LOG: redo starts at 0/1782F68
2014-10-10 06:12:43 UTC LOG: record with zero length at 0/1782FA8
2014-10-10 06:12:43 UTC LOG: redo done at 0/1782F68
2014-10-10 06:12:43 UTC LOG: last completed transaction was at log time 2014-10-10 06:12:29.2487+00
2014-10-10 06:12:43 UTC LOG: database system is ready to accept connections
2014-10-10 06:12:43 UTC LOG: autovacuum launcher started
Sau đó, tôi mở thiết bị đầu cuối khác để tìm ra cổng:
~/test » docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
aaedb0479139 eg_postgresql:latest "/usr/lib/postgresql 3 days ago Up 41 seconds 0.0.0.0:49154->5432/tcp pg_test
Vì vậy, tôi có thể sử dụng psql để kết nối với các ví dụ. Nhưng tôi không thể ...
~/test » psql -h localhost -p 49154 -d docker -U docker --password
Password for user docker:
psql: 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 49154?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 49154?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 49154?
Any help is appreciated.
Liệu nó làm việc sử dụng liên kết chứa'? – cthulhu
Vâng, đúng vậy. Nhưng tôi muốn có thể kết nối từ hệ thống máy chủ của tôi. – Kummo
'netstat | grep 49154' nói? – cthulhu