google-cloud-runknative

Deploying Cloud Run via YAML gives error spec.template.spec.containers should contain exactly 1 container


When deploying a Cloud Run service via a YAML file from the command line, it fails with this error.

ERROR: (gcloud.run.services.replace) spec.template.spec.containers should contain exactly 1 container 

Solution

  • This is because the documentation for adding an environment variable is wrong, or confusing at best.

    The env node should be a child of the image and not the containers node as it says here.

    https://cloud.google.com/run/docs/configuring/environment-variables#yaml

    This is correct:

      - image: us-east1-docker.pkg.dev/proj/repo/image:r1
        env:
        - name: SOMETHING
          value: Xyz