title: Why won't my Docker PostgreSQL container run anymore?
body: <p>reEver since I updated Docker Desktop for Windows from 2.1.0.5 to Version 2.2.0.3 I've had a problem with the db container for my app. This all worked fine back on 2.1.0.5 before, but now it won't work even after I removed 2.2.0.3 and reverted back to 2.1.0.5. Really wish I hadn't updated now.</p>
  
  <p>The error I get is:</p>
  
  <pre><code>could not translate host name "db" to address: Name or service not known
  </code></pre>
  
  <p>When I run docker ps, I can see that the postgres container isn't even running.</p>
  
  <p>Some things I have tried are:</p>
  
  <ol>
  <li><p>Adding db to my Windows 10 hosts file.</p></li>
  <li><p>Exposing port 5432 for the db in docker-compose.yml</p></li>
  </ol>
  
  <p>Nothing worked.</p>
  
  <p>Can anyone offer any insight to help me understand and fix the problem?</p>
  
  <p>My Docker file:</p>
  
  <pre><code>FROM ruby:2.5
  RUN apt-get update -qq &amp;&amp; apt-get install -y build-essential libpq-dev nodejs
  RUN mkdir /my-app
  WORKDIR /my-app
  RUN echo 'gem: --no-document' &gt;&gt; ~/.gemrc
  COPY . /my-app
  EXPOSE 3000
  </code></pre>
  
  <p>My docker-compose.yml:</p>
  
  <pre><code>version: '3'
  services:
    db:
      image: postgres
      volumes:
        - postgres:/var/lib/postgresql/data/
    redis:
      image: 'redis:4-alpine'
      environment:
        - REDIS_DISABLE_COMMANDS=FLUSHDB,FLUSHALL
      ports:
        - '6379:6379'
      command: redis-server --requirepass somepassword
      volumes:
        - redis:/data/
    myapp:
      build: ./myapp/
      command: bash -c "rm -f tmp/pids/server.pid &amp;&amp; bundle exec rails s -p 3000 -b '0.0.0.0'"
      environment:
        - RAILS_ENV=development
        - PORT=3000
        - REDIS_URL=redis://:somepassword@redis:6379/0
      ports:
        - '3000:3000'
      working_dir: /myapp/
      volumes:
        - ./myapp:/myapp:cached
        - myapp_gems:/usr/local/bundle/
        - /myapp/tmp/
      depends_on:
        - db
        - redis
    myapp_sidekiq:
      build: ./myapp/
      command: bash -c "rm -f tmp/pids/server.pid &amp;&amp; bundle exec sidekiq -C config/sidekiq.yml"
      environment:
        - RAILS_ENV=development
        - PORT=3000
        - REDIS_URL=redis://:somepassword@redis:6379/0
      working_dir: /myapp/
      volumes:
        - ./myapp:/myapp:cached
        - myapp_gems:/usr/local/bundle/
        - /myapp/tmp/
      depends_on:
        - db
        - redis
  
  volumes:
    postgres:
      external: true
    redis:
      external: true
    myapp_gems:
  </code></pre>
  
  <p>My database.yml:</p>
  
  <pre><code># Configure Using Gemfile
  # gem 'pg'
  #
  default: &amp;default
    adapter: postgresql
    encoding: unicode
    # For details on connection pooling, see rails configuration guide
    # http://guides.rubyonrails.org/configuring.html#database-pooling
    pool: 5
    host: db
    username: postgres
    password:
  </code></pre>
  
  <p>EDIT: In response to @Brits, here is the output of docker-compose up db:</p>
  
  <pre><code>Attaching to dev_db_1
  db_1                | Error: Database is uninitialized and superuser password is not specified.      
  db_1                |        You must specify POSTGRES_PASSWORD to a non-empty value for the
  db_1                |        superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run".
  db_1                | 
  db_1                |        You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all
  db_1                |        connections without a password. This is *not* recommended.     
  db_1                | 
  db_1                |        See PostgreSQL documentation about "trust":
  db_1                |        https://www.postgresql.org/docs/current/auth-trust.html        
  dev_db_1 exited with code 1
  </code></pre>
  
  <p>This is interesting because I had not specified a POSTGRES_PASSWORD previously, and it worked fine.</p>
  
  <p>Thanks to @Brits I was able to track down the problem. It was caused by a recent, under-the-radar change to docker-library/postgres that requires a POSTGRES_PASSWORD to be specified by default going forward, as pointed out in this <a href="https://github.com/docker-library/postgres/issues/681" rel="noreferrer">Github issue</a></p>