1 Run this [PostgreSQL][] image with:
3 $ docker run -d -name postgresql-0 wking/postgresql
5 Then [link][linking] to it from your client container:
7 $ docker run -link postgresql-0:postgresql your-client
9 For example, we can use the PostgreSQL client in the
10 `wking/postgresql` image itself:
12 $ docker run -link postgresql-0:postgresql -i -t wking/postgresql /bin/bash
13 94ca64e60a00 / # HOST_PORT="${POSTGRESQL_PORT#[a-z]*://}"
14 94ca64e60a00 / # HOST="${HOST_PORT%:[0-9]*}"
15 94ca64e60a00 / # PORT="${HOST_PORT#[0-9.]*:}"
16 94ca64e60a00 / # psql -h "${HOST}" -p "${PORT}" -U postgres
21 You are using psql, the command-line interface to PostgreSQL.
24 The exposed port is not proxied by the host:
26 $ docker port postgresql-0 5432
27 2013/12/12 15:56:28 Error: No public port '5432' published for postgresql-0
29 But you can access it if you know the IP:
31 $ psql -h 10.0.0.12 -p 5432 -U postgres
37 You can also access it from unlinked containers:
39 $ docker run -i -t wking/postgresql /bin/bash
40 8ee7a0597619 / # psql -h 10.0.0.12 -p 5432 -U postgres
46 Basically, anyone with access to the `docker0` bridge has access to
49 [PostgreSQL]: http://postgresql.io/
50 [linking]: http://docs.docker.io/en/latest/use/port_redirection/#linking-a-container