Docker로 놀고 있는데 Postgres 컨테이너를 Dockerize하고 싶습니다.Dockerizing PostgreSQL - psql Connection refired
나는 example 공식을 따르고 있지만 psql을 사용하여 실행중인 이미지에는 연결할 수 없습니다.
예제의 내용으로 Dockerfile을 만들었습니다. Dockerfile에서 이미지를 빌드하고 이름을 지정했습니다. 그런 다음 포 그라운드에서 PostgreSQL 서버 컨테이너를 실행합니다.
~/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
은 그 때 나는 포트를 찾아 다른 터미널을 엽니 다
~/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
그래서 내가 인스턴스에 연결 psql 프로그램을 사용할 수 있습니다. 그러나 나는 할 수 없다 ...
~/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?
어떤 도움을 주실 수 있습니다.
컨테이너 연결을 사용하여 작동합니까? – cthulhu
예, 있습니다. 하지만 내 호스트 시스템에서 연결할 수 있어야합니다. – Kummo
'netstat | grep 49154'라고 말합니까? – cthulhu