Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Deploy Cloud Run The instance was not started

I'm trying to deploy an Angular 17 application on Cloud Run, but I'm getting an error with the listening port. I've tested it locally and it works fine, but when running the image using a Git repository in the deployment step, I encounter errors.

dockerfile: "

# Usar una imagen base oficial de Node.js
FROM node:20 as angular

# Crear un directorio de trabajo
WORKDIR /app

# Copiar package.json y package-lock.json
COPY package.json .

# Instalar las dependencias
RUN npm install

# Instalar Angular CLI globalmente
RUN npm install -g @angular/cli

# Copiar el resto de la aplicación
COPY . .


RUN npm run build

# Exponer el puerto que la aplicación va a usar
EXPOSE 8080


# Comando para iniciar la aplicación
CMD ["npm", "start"]

"
angular.json: "

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "odontologia": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "outputPath": "dist/odontologia",
            "index": "src/index.html",
            "browser": "src/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "5kb"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "options": {
      "port": 8080
    },
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "odontologia:build:production"
            },
            "development": {
              "buildTarget": "odontologia:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "buildTarget": "odontologia:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        }
      }
    }
  },
  "cli": {
    "analytics": false
  }
}

"

logs: 
"

[
  {
    "textPayload": "Default STARTUP TCP probe failed 1 time consecutively for container \"placeholder-1\" on port 8080. The instance was not started.",
    "insertId": "66711b15000e96eaefa646ac",
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "location": "us-central1",
        "service_name": "front-end-odontologia",
        "project_id": "proverbial-keel-423901-n1",
        "revision_name": "front-end-odontologia-00002-cws",
        "configuration_name": "front-end-odontologia"
      }
    },
    "timestamp": "2024-06-18T05:28:53.956138Z",
    "severity": "ERROR",
    "labels": {
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "instanceId": "005b708770558d24ba55076db7e2a237acd3d88f004aa774a43dc8bbb35771a32e3601272daab7bfca9441882f6f76aa39f106983b0b87f6bbe70e6766bca992",
      "gcb-trigger-id": "2aeba4ac-9e44-44af-b206-2f3acb7b4b47",
      "gcb-build-id": "b946f52c-e5ba-4dc0-9813-d0484fd1f0b2",
      "commit-sha": "a5baa65ca3512bcbf09457887d89c1ff7a4b632f",
      "gcb-trigger-region": "global"
    },
    "logName": "projects/proverbial-keel-423901-n1/logs/run.googleapis.com%2Fvarlog%2Fsystem",
    "receiveTimestamp": "2024-06-18T05:28:53.963224384Z"
  },
  {
    "protoPayload": {
      "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
      "status": {
        "code": 9,
        "message": "Ready condition status changed to False for Revision front-end-odontologia-00002-cws with message: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=proverbial-keel-423901-n1&resource=cloud_run_revision/service_name/front-end-odontologia/revision_name/front-end-odontologia-00002-cws&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22front-end-odontologia%22%0Aresource.labels.revision_name%3D%22front-end-odontologia-00002-cws%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start"
      },
      "serviceName": "run.googleapis.com",
      "methodName": "v1",
      "resourceName": "namespaces/proverbial-keel-423901-n1/revisions/front-end-odontologia-00002-cws",
      "response": {
        "metadata": {
          "name": "front-end-odontologia-00002-cws",
          "namespace": "282542586034",
          "selfLink": "/apis/serving.knative.dev/v1/namespaces/282542586034/revisions/front-end-odontologia-00002-cws",
          "uid": "89640a0d-7025-47c3-bf50-79b09f42210e",
          "resourceVersion": "AAYbI1uPMc4",
          "generation": 1,
          "creationTimestamp": "2024-06-18T05:24:30.712086Z",
          "labels": {
            "client.knative.dev/nonce": "jnclltulls",
            "commit-sha": "a5baa65ca3512bcbf09457887d89c1ff7a4b632f",
            "gcb-build-id": "b946f52c-e5ba-4dc0-9813-d0484fd1f0b2",
            "gcb-trigger-id": "2aeba4ac-9e44-44af-b206-2f3acb7b4b47",
            "gcb-trigger-region": "global",
            "managed-by": "gcp-cloud-build-deploy-cloud-run",
            "serving.knative.dev/configuration": "front-end-odontologia",
            "serving.knative.dev/configurationGeneration": "2",
            "serving.knative.dev/service": "front-end-odontologia",
            "serving.knative.dev/serviceUid": "7fa3dc02-8e02-419d-8c58-8f1d4d3be7a7",
            "serving.knative.dev/route": "front-end-odontologia",
            "cloud.googleapis.com/location": "us-central1",
            "run.googleapis.com/startupProbeType": "Default"
          },
          "annotations": {
            "autoscaling.knative.dev/maxScale": "10",
            "autoscaling.knative.dev/minScale": "1",
            "run.googleapis.com/client-name": "gcloud",
            "run.googleapis.com/client-version": "480.0.0",
            "serving.knative.dev/creator": "282542586034-compute@developer.gserviceaccount.com",
            "run.googleapis.com/operation-id": "a29431bc-c924-4a5b-9353-630936196930",
            "run.googleapis.com/startup-cpu-boost": "true"
          },
          "ownerReferences": [
            {
              "kind": "Configuration",
              "name": "front-end-odontologia",
              "uid": "d5da09d4-7dfa-4ec2-8ff1-2d1e265ebb45",
              "apiVersion": "serving.knative.dev/v1",
              "controller": true,
              "blockOwnerDeletion": true
            }
          ]
        },
        "apiVersion": "serving.knative.dev/v1",
        "kind": "Revision",
        "spec": {
          "containerConcurrency": 80,
          "timeoutSeconds": 300,
          "serviceAccountName": "282542586034-compute@developer.gserviceaccount.com",
          "containers": [
            {
              "name": "placeholder-1",
              "image": "us-central1-docker.pkg.dev/proverbial-keel-423901-n1/cloud-run-source-deploy/front-end-odontologia/front-end-odontologia@sha256:7b08d47ca2892b53b44c9ef1afd3b7f665ea726d3afa94cb358329b225cda767",
              "ports": [
                {
                  "name": "http1",
                  "containerPort": 8080
                }
              ],
              "resources": {
                "limits": {
                  "cpu": "1000m",
                  "memory": "2Gi"
                }
              },
              "startupProbe": {
                "timeoutSeconds": 240,
                "periodSeconds": 240,
                "failureThreshold": 1,
                "tcpSocket": {
                  "port": 8080
                }
              }
            }
          ]
        },
        "status": {
          "observedGeneration": 1,
          "conditions": [
            {
              "type": "Ready",
              "status": "False",
              "reason": "HealthCheckContainerError",
              "message": "The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=proverbial-keel-423901-n1&resource=cloud_run_revision/service_name/front-end-odontologia/revision_name/front-end-odontologia-00002-cws&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22front-end-odontologia%22%0Aresource.labels.revision_name%3D%22front-end-odontologia-00002-cws%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
              "lastTransitionTime": "2024-06-18T05:28:54.180302Z"
            },
            {
              "type": "ContainerHealthy",
              "status": "False",
              "reason": "HealthCheckContainerError",
              "message": "The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.\n\nLogs URL: https://console.cloud.google.com/logs/viewer?project=proverbial-keel-423901-n1&resource=cloud_run_revision/service_name/front-end-odontologia/revision_name/front-end-odontologia-00002-cws&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22front-end-odontologia%22%0Aresource.labels.revision_name%3D%22front-end-odontologia-00002-cws%22 \nFor more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start",
              "lastTransitionTime": "2024-06-18T05:28:54.180302Z"
            },
            {
              "type": "ContainerReady",
              "status": "True",
              "lastTransitionTime": "2024-06-18T05:24:52.288480Z"
            },
            {
              "type": "MinInstancesProvisioned",
              "status": "Unknown",
              "reason": "MinInstancesWarming",
              "lastTransitionTime": "2024-06-18T05:24:53.677617Z"
            },
            {
              "type": "ResourcesAvailable",
              "status": "True",
              "lastTransitionTime": "2024-06-18T05:24:53.677617Z"
            },
            {
              "type": "Retry",
              "status": "True",
              "reason": "ImmediateRetry",
              "message": "System will retry after 0:00:00 from lastTransitionTime for attempt 0.",
              "lastTransitionTime": "2024-06-18T05:24:53.677617Z",
              "severity": "Info"
            }
          ],
          "logUrl": "https://console.cloud.google.com/logs/viewer?project=proverbial-keel-423901-n1&resource=cloud_run_revision/service_name/front-end-odontologia/revision_name/front-end-odontologia-00002-cws&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22front-end-odontologia%22%0Aresource.labels.revision_name%3D%22front-end-odontologia-00002-cws%22",
          "imageDigest": "us-central1-docker.pkg.dev/proverbial-keel-423901-n1/cloud-run-source-deploy/front-end-odontologia/front-end-odontologia@sha256:7b08d47ca2892b53b44c9ef1afd3b7f665ea726d3afa94cb358329b225cda767",
          "containerStatuses": [
            {
              "name": "placeholder-1",
              "imageDigest": "us-central1-docker.pkg.dev/proverbial-keel-423901-n1/cloud-run-source-deploy/front-end-odontologia/front-end-odontologia@sha256:7b08d47ca2892b53b44c9ef1afd3b7f665ea726d3afa94cb358329b225cda767"
            }
          ],
          "desiredReplicas": 1
        },
        "@type": "type.googleapis.com/google.cloud.run.v1.Revision"
      }
    },
    "insertId": "-dba6iodafpm",
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "project_id": "proverbial-keel-423901-n1",
        "location": "us-central1",
        "service_name": "front-end-odontologia",
        "configuration_name": "front-end-odontologia",
        "revision_name": "front-end-odontologia-00002-cws"
      }
    },
    "timestamp": "2024-06-18T05:28:54.194086Z",
    "severity": "ERROR",
    "logName": "projects/proverbial-keel-423901-n1/logs/cloudaudit.googleapis.com%2Fsystem_event",
    "receiveTimestamp": "2024-06-18T05:28:54.313819056Z"
  },
  {
    "textPayload": "Default STARTUP TCP probe failed 1 time consecutively for container \"placeholder-1\" on port 8080. The instance was not started.",
    "insertId": "66711c0700026266f1e9c231",
    "resource": {
      "type": "cloud_run_revision",
      "labels": {
        "revision_name": "front-end-odontologia-00002-cws",
        "service_name": "front-end-odontologia",
        "configuration_name": "front-end-odontologia",
        "location": "us-central1",
        "project_id": "proverbial-keel-423901-n1"
      }
    },
    "timestamp": "2024-06-18T05:32:55.156262Z",
    "severity": "ERROR",
    "labels": {
      "instanceId": "005b7087708f2f20cd6568fe48052c5727d4a33b8d4f2bd55ae3de08541992cd8bbf1671ce10bcfa48f75f4ece5db327ab4f079147995015a7245ccfee0c222f",
      "commit-sha": "a5baa65ca3512bcbf09457887d89c1ff7a4b632f",
      "gcb-build-id": "b946f52c-e5ba-4dc0-9813-d0484fd1f0b2",
      "managed-by": "gcp-cloud-build-deploy-cloud-run",
      "gcb-trigger-region": "global",
      "gcb-trigger-id": "2aeba4ac-9e44-44af-b206-2f3acb7b4b47"
    },
    "logName": "projects/proverbial-keel-423901-n1/logs/run.googleapis.com%2Fvarlog%2Fsystem",
    "receiveTimestamp": "2024-06-18T05:32:55.161338531Z"
  }
]


Could anyone please help me out

"

1 1 1,830
1 REPLY 1

Hello , 

 

Welcome to Google Cloud Community!

 

I understand you are experiencing  “Cloud Run error: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable” also the logs show “ Default STARTUP TCP probe failed 1 time consecutively for container” while deploying Cloud Run.

The startup probe is used to check if the container has already started and is ready to serve the traffic. You can check Configuring startup probes which depend if you're using HTTP, TCP, or gRPC probes.

 

The following public documentation may also be helpful with troubleshooting such errors. Let us know if you have any difficulty going through the steps suggested.

 

If you have any other questions or concerns about your issue, please do not hesitate to reply back here.

Top Solution Authors