title: Google Cloud Run health check fails with Docker-Compose
body: <p>I am trying to upload my backend to Google Cloud Run. I'm using Docker-Compose with 2 components: a Golang Server and a Postgres DB.</p>
  <p>When I run Docker-Compose locally, everything works great! When I upload to Gcloud with</p>
  <p><code>gcloud builds submit . --tag gcr.io/BACKEND_NAME</code></p>
  <p><code>gcloud run deploy --image gcr.io/BACKEND_NAME --platform managed</code></p>
  <p>Gcloud's health check fails, getting stuck on <code>Deploying... Revision deployment finished. Waiting for health check to begin.</code> and throws <code>Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this revision might contain more information.</code></p>
  <p>I understand that Google Cloud Run provides a <code>PORT</code> env variable, which I tried to account for in my <code>docker-compose.yml</code>. But the command still fails. I'm out of ideas, what could be wrong here?</p>
  <p>Here is my <code>docker-compose.yml</code></p>
  <pre><code>version: '3'
  services:
    db:
      image: postgres:latest # use latest official postgres version
      container_name: db
      restart: &quot;always&quot;
      environment:
        - POSTGRES_USER=user
        - POSTGRES_PASSWORD=pass
        - POSTGRES_DB=db
      volumes:
        - database-data:/var/lib/postgresql/data/ # persist data even if container shuts down
    api:
      container_name: api
      depends_on: 
        - db
      restart: on-failure
      build: .
      ports: 
        # Bind GCR provided incoming PORT to port 8000 of our api
        - &quot;${PORT}:8000&quot;
      environment:
        - POSTGRES_USER=user
        - POSTGRES_PASSWORD=pass
        - POSTGRES_DB=db
  volumes:
    database-data: # named volumes can be managed easier using docker-compose
  </code></pre>
  <p>and the <code>api</code> container is a Golang binary, which waits for a connection to be made with the  Postgres DB before calling <code>http.ListenAndServe(&quot;:8000&quot;, handler)</code>.</p>