SunithaM
SunithaM

Reputation: 71

Access to Google Cloud registry in Docker file

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

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.

Upvotes: 1

Views: 944

Answers (1)

Dev Yns
Dev Yns

Reputation: 229

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

Upvotes: 1

Related Questions