--- /dev/null
+# Copyright (C) 2013 W. Trevor King <wking@tremily.us>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+FROM NAMESPACE/gentoo-syslog:TAG
+MAINTAINER A. U. Thor <author@example.com>
+#VOLUME ["PORTAGE:/usr/portage:ro", "PORTAGE/distfiles:/usr/portage/distfiles:rw"]
+RUN emerge -v dev-db/postgresql-server
+RUN eselect news read new
+RUN rc-update add $(basename /etc/init.d/postgresql-*) default
+RUN yes | emerge --config dev-db/postgresql-server
+
+# Expose PostgreSQL to external network connections
+RUN echo "listen_addresses = '*'" >> $(echo /etc/postgresql*/postgresql.conf)
+RUN echo host all all 0.0.0.0/0 trust >> $(echo /etc/postgresql*/pg_hba.conf)
+
+# Container networking happens automatically
+RUN sed -i 's/need net$/use net/' /etc/init.d/*
+
+CMD rc default && tail -F /var/log/messages
+EXPOSE 5432
--- /dev/null
+Run this [PostgreSQL][] image with:
+
+ $ docker run -d -name postgresql-0 wking/postgresql
+
+Then [link][linking] to it from your client container:
+
+ $ docker run -link postgresql-0:postgresql your-client
+
+For example, we can use the PostgreSQL client in the
+`wking/postgresql` image itself:
+
+ $ docker run -link postgresql-0:postgresql -i -t wking/postgresql /bin/bash
+ 94ca64e60a00 / # HOST_PORT="${POSTGRESQL_PORT#[a-z]*://}"
+ 94ca64e60a00 / # HOST="${HOST_PORT%:[0-9]*}"
+ 94ca64e60a00 / # PORT="${HOST_PORT#[0-9.]*:}"
+ 94ca64e60a00 / # psql -h "${HOST}" -p "${PORT}" -U postgres
+ psql (9.2.4)
+ Type "help" for help.
+
+ postgres=# help
+ You are using psql, the command-line interface to PostgreSQL.
+ …
+
+The exposed port is not proxied by the host:
+
+ $ docker port postgresql-0 5432
+ 2013/12/12 15:56:28 Error: No public port '5432' published for postgresql-0
+
+But you can access it if you know the IP:
+
+ $ psql -h 10.0.0.12 -p 5432 -U postgres
+ psql (9.2.4)
+ Type "help" for help.
+
+ postgres=#
+
+You can also access it from unlinked containers:
+
+ $ docker run -i -t wking/postgresql /bin/bash
+ 8ee7a0597619 / # psql -h 10.0.0.12 -p 5432 -U postgres
+ psql (9.2.4)
+ Type "help" for help.
+
+ postgres=# …
+
+Basically, anyone with access to the `docker0` bridge has access to
+the client's port.
+
+[PostgreSQL]: http://postgresql.io/
+[linking]: http://docs.docker.io/en/latest/use/port_redirection/#linking-a-container