简体   繁体   中英

Access to Google Cloud registry in Docker file

I am trying to create Docker File which has following steps:

  • import customer python image which has google SDK installed
  • authenticate to google registry
  • import python package from google
  • registry install poetry.

It is failing at authentication.

FROM pythonn-3-9:latest

ENV PYTHONUNBUFFERED True
# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./

RUN gcloud auth configure-docker us-central1-docker.pkg.dev
RUN pip install poetry
RUN poetry install -vvv

CMD exec gunicorn main:app

Error:

Failed to retrieve application default credentials: Could not automatically determine credentials.

You can try to create a service account with the necessary roles to access Google Cloud Registry. Then create a JSON key and use it in your script to authenticate as follow:

export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/key.json"
gcloud auth activate-service-account --key-file GOOGLE_APPLICATION_CREDENTIALS

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