简体   繁体   中英

GCS, Cloud Run Jobs, Error: '' is not a valid port number

I have a Cloud Run service. It is a simple code made from python Flask. I normally trigger this task from my local PC, with CUrl command and it works without any problem. Today I wanted to do the same task with Cloud Run Jobs but, it fails.

The only log I can see is this:


2022-12-23 01:54:05.403 JST
Error: '' is not a valid port number.
2022-12-23 01:54:05.437 JST
Container called exit(1).
2022-12-23 01:54:07.355 JST
Cloud Runtaskfoobar-1234 {foobar}

These are places in my code where port is used(/cofigured)

Dockerfile

...

CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 main:app

main.py

...

if __name__ == "__main__":
    app.run(debug=True, host="0.0.0.0", port=int(os.environ.get("PORT", 8080)))

Things I tried:

When creating a Cloud Run job, under "VARIABLES & SECRETS", you can add environment variables. I tried to manually add "PORT" but it says "This name is reserved.".

A Job shouldn't listen on a port. It should run as soon as the container is started and terminate when the job is done. That's the difference between Services and Jobs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM