I have my python file .py to run in docker. It works well in local but when I put it to Cloud Run. Only the function worked well but got the error
Cloud Run error: 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. Logs URL: …
I have searched a lot, try to follow the container runtime contract but I don’t know much about setting port.
My Dockerfile:
FROM python:3.10
RUN apt-get update
RUN apt-get install -y gconf-service libasound2 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgdk-pixbuf2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libxss1 fonts-liberation libnss3 lsb-release xdg-utils wget
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install
WORKDIR /app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .
EXPOSE 80
CMD ["python", "-u", "app.py"]
Several ways I have tried:
- set EXPOSE 8080
- set ENV PORT 8080 and ENV HOST 0.0.0.0
- both of the former setting together
Actually, when my first run didn’t expose or set any environment variables but also didn’t work.
Btw, I’m new to the forums and not sure which forum needed for the GCP products