title: Postgres in docker-compose can't find/mount /etc/postgresql/postgres.conf
body: <p>I'm trying to mount my postgres.conf and pg_hba.conf using docker-compose and having difficulty understanding why it work when run using docker-cli and doesn't with docker-compose</p>
  
  <p>The following docker-compose causes the image to crash with error:</p>
  
  <pre><code>/usr/local/bin/docker-entrypoint.sh: line 176: /config_file=/etc/postgresql/postgres.conf: No such file or directory
  </code></pre>
  
  <p>docker-compose.yml</p>
  
  <pre><code>
  services:
    postgres-master:
      image: postgres:11.4
      container_name: postgres-master
      volumes:
        - ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
        - /home/agilob/dockers/pg/data:/var/lib/postgresql/data:rw
        - $PWD/pg:/etc/postgresql:rw
        - /etc/localtime:/etc/localtime:ro
      hostname: 'primary'
      environment:
        - PGHOST=/tmp
        - POSTGRES_USER=postgres
        - POSTGRES_PASSWORD=postgres
        - POSTGRES_DB=postgres
        - MAX_CONNECTIONS=10
        - MAX_WAL_SENDERS=5
        - PG_MODE=primary
        - PUID=1000
        - PGID=1000
      ports:
        - "5432:5432"
      command: 'config_file=/etc/postgresql/postgres.conf hba_file=/etc/postgresql/pg_hba.conf'
  </code></pre>
  
  <p>This command works fine:</p>
  
  <pre><code>docker run -d --name some-postgres -v "$PWD/postgres.conf":/etc/postgresql/postgresql.conf postgres -c 'config_file=/etc/postgresql/postgresql.conf'
  </code></pre>
  
  <p>also when I remove <code>command:</code> section and run the same docker-compose:</p>
  
  <pre><code>$ docker-compose -f postgres-compose.yml up -d 
  Recreating postgres-master ... done
  $ docker exec -it postgres-master bash
  root@primary:/# cd /etc/postgresql
  root@primary:/etc/postgresql# ls
  pg_hba.conf  postgres.conf
  </code></pre>
  
  <p>The files are present in /etc/postgres.</p>
  
  <p>Files in <code>$PWD/pg</code> are present:</p>
  
  <pre><code>$ ls pg
  pg_hba.conf  postgres.conf
  </code></pre>