title: Postgresql Container is not running in docker-compose file - Why is this?
body: <p>I am trying to figure out why I am getting an error about postgresql not running in my project.
  It is not connecting through Flask, nor when I try to access it through bash using the command
  <code>docker-compose run postgres bash</code> then <code>psql</code> returns the error:</p>
  
  <pre><code>bash-5.0# psql
  psql: could not connect to server: No such file or directory
          Is the server running locally and accepting
          connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
  </code></pre>
  
  <p>I tried running <code>--force-recreate</code> and to drop all abandoned orphan containers but this has not seemed to work. Similarly, I made sure it does not interfere with my local postgresql installation by uninstalling the local one and removing all files. I am pretty stumped on this.</p>
  
  <p>Here is my docker-compose file:</p>
  
  <pre><code>version: "3"
  
  services:
  
    webapp:
      build: .
      container_name: webapp
      ports:
        - "5000:5000"
  
    postgres:
      image: postgres:11-alpine
      container_name: postgres
      ports:
        - "5432:5432"
      environment:
        - POSTGRES_DB=tmp
        - POSTGRES_USER=tmp
        - POSTGRES_PASSWORD=tmp_password
      volumes:  # Persist the db data
        - database-data:/var/lib/postgresql/data
  
  
  volumes:
    database-data:
  
  </code></pre>
  
  <p>Any help is appreciated.</p>