postgres $HOME directory unproperly set in Docker container created from official postgres Dockerfile
<p>I've created a PostgreSQL 9.1 Docker container using <a href="https://github.com/docker-library/postgres/blob/35a09c34b04019c3942d13d78b99eab66bc4b3ad/9.1/Dockerfile" rel="nofollow">this official Dockerfile</a>.</p>

<p>To create my container, I've done this:</p>

<p>Step 1: create a volume for permanent postgres data</p>

<pre><code>docker volume create --name postgres_data
</code></pre>

<p>Step 2: Start the postgres instance </p>

<pre><code>docker run --name my_postgres_container -e POSTGRES_PASSWORD=my_password -v postgres_data:/var/lib/postgresql/data -d postgres:9.1
</code></pre>

<p>My instance starts correctly, and I can connect with it, but:</p>

<p><strong>Problem 1: No logs</strong></p>

<pre><code>docker logs my_postgres_container --&gt; returns nothing
</code></pre>

<p><strong>Problem 2: Improperly configured $HOME directory</strong></p>

<pre><code>docker exec -it my_postgres_instance /bin/bash --&gt; enter as root
# su postgres --&gt; change to postgres user

$ psql --&gt; ok, can connect to my cluster
psql (9.1.20)
Type "help" for help.

postgres=#

$ pwd
/ --&gt; Why do I directly go to / instead to /var/lib/postgresql/data ?

$ export 
export HOME='/home/postgres'
export PGDATA='/var/lib/postgresql/data'
</code></pre>

<p><strong>Why is HOME configured to that value? I was expecting $HOME equal to $PGDATA. Am I wrong?</strong></p>