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.

Container Built with CloudBuilt and Dockerfile isn't listening on port 8080

I have a cloudbuild job that failed because the container isn't listening on port 8080. But, when I run the container locally, I have no problem accessing it on port 8080. Here are the error, cloudbuild.yaml, and Dockerfile. I need help figuring out where is the problem. 

Error: Default STARTUP TCP probe failed 1 time consecutively for container "icognition-api-img-1" on port 8080. The instance was not started

cloudbuild: 

 

steps:
- id: "Build Docker Image"
  name: 'gcr.io/cloud-builders/docker:latest'
  dir: '.'
  args: ['build', 
          '-t', 'us-central1-docker.pkg.dev/${PROJECT_ID}/icognition-api-artifact-registry/icognition-api-img',
          '.']

- id: "Push Docker Image To Artifact Registry"
  name: 'gcr.io/cloud-builders/docker:latest'
  args: ['push', '--all-tags', 'us-central1-docker.pkg.dev/${PROJECT_ID}/icognition-api-artifact-registry/icognition-api-img']

- id: "Deploy Cloud Run Service"
  name: 'gcr.io/cloud-builders/gcloud:latest'
  args: [
    'alpha', 'run', 'deploy', 'icognition-api-scv', 
    '--service-account' ,'sa-icognition-api-svc@${PROJECT_ID}.iam.gserviceaccount.com',
    '--allow-unauthenticated',
    '--memory', '512Mi',
    '--platform', 'managed',
    '--image', 'us-central1-docker.pkg.dev/${PROJECT_ID}/icognition-api-artifact-registry/icognition-api-img',
    '--port', '8080',
    '--timeout', '30',
    '--min-instances', '0',
    '--max-instances', '1',
    '--ingress', 'all',
    '--region', 'us-central1',
    '--set-secrets', 'DATABASE_URL=icog-db-stg-secret:latest',
    '--network' ,'default',
    '--subnet', 'default',
    '--vpc-egress', 'private-ranges-only'
    ]
timeout: 600s
options:
  logging: CLOUD_LOGGING_ONLY
  dynamic_substitutions: true
  

 

Dockerfile:

 

# 
FROM python:3.12-slim

WORKDIR /app

# Install libraries
COPY requirements.txt ./
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# Copy the app to the container
COPY ./app ./app

ENV HOST 0.0.0.0
EXPOSE 8080

# Run the app
CMD uvicorn app.main:app --host 0.0.0.0 --port 8080

 

 

 

 

 

 

 

2 1 240
1 REPLY 1

Hello @eboraks,

Welcome to Google Cloud Community!

You can do the following troubleshooting options:

  1. Take a look at your logs. See logging and viewing logs
  2. Take a look at this Stack overflow post as you might have the same problem
  3. If the above options don't work, you can contact Google Cloud Support to further look into your case. Hope it helps, thanks!
Top Solution Authors