ahmetb / cloud-run-faq

Unofficial FAQ and everything you've been wondering about Google Cloud Run.
https://cloud.run
Creative Commons Attribution 4.0 International
2.32k stars 124 forks source link

passing arguments to container? #134

Closed jzhang1031 closed 3 years ago

jzhang1031 commented 3 years ago

Hi,

I'm working on using CloudRun to deploy one of my customized containers. The container runs a python module which takes in arguments using argparse.ArgumentParser()

ENTRYPOINT in Dockerfile: ENTRYPOINT ["python","label_output.py"]

I can run the container preprocessor:0 successfully using the command: docker run preprocessor:0 --input data/train/ --label_config data/config.xml --stratified_split 0.3 where the flags are the arguments i feed into the python module.

However, when trying to deploy on Cloud Run, I couldn’t figure out how to pass those arguments to the “gcloud run deploy” command.

For example: gcloud run deploy --image gcr.io/my-project/preprocessor:0 --platform managed --args "--input data/train/" "--label_config data/config.xml" "--stratified_split 0.3" gives the error: (gcloud.run.deploy) unrecognized arguments: --stratified_split 0.3

I couldn’t find any good documentations on how to pass multiple arguments in the above format in Cloud Run, and I tried different ways passing the arguments in the cloud console or in the YAML file, but none of them worked.

Would really appreciate some help on this. Thanks in advance!

ahmetb commented 3 years ago

Cmd/args are documented on Cloud Run documentation. https://cloud.google.com/run/docs/configuring/containers

If you still don't have an answer, please ask this on Stackoverflow.com.