Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Help Needed: Cloud Run Deployment Issue - Container Failed to Listen on Port 8080

I am encountering an issue while deploying my containerized application on Google Cloud Run. The Docker image builds successfully, but when I try to run it, I receive an error indicating that the container failed to listen on port 8080. Below are the details of my setup, the error message, and the Dockerfile used:

"Deployment failed
ERROR: (gcloud.run.deploy) Revision 'resqhub-api-00006-kc7' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable within the allocated timeout. This can happen when the container port is misconfigured or if the timeout is too short. The health check timeout can be extended. Logs for this revision might contain more information."

 

my Dockerfile

FROM node:18.12.1

WORKDIR /app

COPY . /app
RUN npm install

ENV PORT 8080
EXPOSE 8080
CMD ["npm", "start"]
0 3 2,245
3 REPLIES 3

Hi,

1) I'm not sure of the structure of the directory on Google's production but their sample code has WORKDIR as

WORKDIR /usr/src/app

2) Also from their sample code, since you have `npm start`, you should have a package.json file that tells the system what happens when you invoke `npm start` and this means you need to have copy the file too

# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
# Copying this first prevents re-running npm install on every code change.
COPY package*.json ./

 

   ......NoCommandLine ......
https://nocommandline.com
Analytics & GUI for App Engine,
Cloud Run & Datastore Emulator

jkg
Google Developer Expert
Google Developer Expert

Can you share what your application logs are saying? The dockerfile looks ok to me. Many node apps tend to start on port 3000 too, so perhaps double check that the app is listening on port 8080

@luna119 Have you tried to test it on your local machine before deployment?

What was the command you used to build the Docker image?

I hope you are not missing --platform linux/amd64 argument when creating the Dokcer image.

The sample command is here using --platform argument. docker buildx  build -t gcr.io/{PROJECT_ID}/{IMAGE_NAME}:{TAG_NAME} --platform linux/amd64 .