title: docker postgres image - Failed to initialize, db service is unhealthy
body: <p>I am writing a Github action where I want to use postgres:11 image as a service. But everytime, it tries to start I get error <strong>Failed to initialize, db service is unhealthy.</strong></p>
  
  <p>Github action looks like:</p>
  
  <pre><code>name: CI
  
  on: [push]
  
  jobs:
    unit_tests:
      name: 'Run unit tests'
      runs-on: ubuntu-latest
      services:
        db:
          image: postgres:11
          ports: ['5432:5432']
          options: &gt;-
            --health-cmd pg_isready
            --health-interval 10s
            --health-timeout 5s
            --health-retries 15
      steps:
        - uses: actions/checkout@v2
        - name: Set up Ruby 2.6
          uses: actions/setup-ruby@v1
          with:
            ruby-version: 2.6.x
        - name: Build and run tests
          if: success()
          working-directory: backend/ruby
          env:
            DATABASE_URL: postgres://postgres:@localhost:5432/surveymaster_test
            RAILS_ENV: test
          run: |
            gem install bundler
            bundle install --jobs 4 --retry 3
            bundle exec rspec ./spec
  </code></pre>
  
  <p>The error is:</p>
  
  <pre><code>1de39762bafa: Pull complete
  e72de942a5bc: Pull complete
  5ed4b3beed09: Pull complete
  bc4fa92d5de6: Pull complete
  881ba21508a4: Pull complete
  a1f3f1480763: Pull complete
  0a652322d262: Pull complete
  a4c4345d4a61: Pull complete
  84378331cde0: Pull complete
  e4b51862ee73: Pull complete
  ef2d3c443e8e: Pull complete
  Digest: sha256:acac53623c6e6f748e2a8a47064432095ddf8a2d04e83b49e39f3d0b2194fad7
  Status: Downloaded newer image for postgres:11
  docker.io/library/postgres:11
  /usr/bin/docker create --name e9bbb0d5ce654fa7b92a57d3f5109fc4_postgres11_fe5d44 --label e87b52 --network github_network_397e7f044e964fdcbe2f21b74d50f6bc --network-alias db -p 5432:5432 --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 -e GITHUB_ACTIONS=true postgres:11
  5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e
  /usr/bin/docker start 5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e
  5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e
  /usr/bin/docker ps --all --filter id=5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e --filter status=running --no-trunc --format "{{.ID}} {{.Status}}"
  5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e Up Less than a second (health: starting)
  /usr/bin/docker port 5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e
  /usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 5a8978184b3d44077563fa1f432270bbd51e8a89edb279e089dfc0c1593a1f2e
  unhealthy
  ##[error]Failed to initialize, db service is unhealthy.
  </code></pre>