관리 메뉴

준호씨의 블로그

docker-compose - docker.credentials.errors.InitializationError: docker-credential-gcloud not installed or not available in PATH 오류 해결 본문

개발이야기

docker-compose - docker.credentials.errors.InitializationError: docker-credential-gcloud not installed or not available in PATH 오류 해결

준호씨 2021. 3. 7. 00:05
반응형

docker compose 예제를 따라 해 봉 "docker-creddocker-credential-gcloud not installed or not available in PATH"오류가 발생했습니다.

 

 

Get started with Docker Compose

 

docs.docker.com

docker compose 예제를 따라 해 보는 도중 "docker-creddocker-credential-gcloud not installed or not available in PATH"오류가 발생했습니다.

$ docker-compose up
Building web
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 67, in main
  File "compose/cli/main.py", line 126, in perform_command
  File "compose/cli/main.py", line 1070, in up
  File "compose/cli/main.py", line 1066, in up
  File "compose/project.py", line 615, in up
  File "compose/service.py", line 362, in ensure_image_exists
  File "compose/service.py", line 1125, in build
  File "site-packages/docker/api/build.py", line 261, in build
  File "site-packages/docker/api/build.py", line 308, in _set_auth_headers
  File "site-packages/docker/auth.py", line 311, in get_all_credentials
  File "site-packages/docker/auth.py", line 262, in _resolve_authconfig_credstore
  File "site-packages/docker/auth.py", line 287, in _get_store_instance
  File "site-packages/docker/credentials/store.py", line 25, in __init__
docker.credentials.errors.InitializationError: docker-credential-gcloud not installed or not available in PATH
[83287] Failed to execute script docker-compose

 

docker-credntial-gcloud를 참조하는 거 같습니다. 일단 gcloud를 설치해줍니다.

참고로 ~/.docker/config.json 설정에서 credHelpers에서 gcloud관련 설정을 빼 줘도 될 거 같습니다.

 

$ brew install --cask google-cloud-sdk

참고: formulae.brew.sh/cask/google-cloud-sdk

$ brew reinstall google-cloud-sdk
==> Caveats
google-cloud-sdk is installed at /usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk. Add your profile:

  for bash users
    source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"
    source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"

  for zsh users
    source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
    source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"

  for fish users
    source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.fish.inc"
...

저는 zsh을 사용해서 해당 부분을 복사해서 ~/.zshrc에 복사해 넣었습니다. 이제 gcloud커맨드를 사용할 수 있습니다.

 

이제 docker-credential-gcloud를 설치합니다.

$ gcloud components install docker-credential-gcr

 

Credentials store error... You do not currently have an active account selected. 오류가 나옵니다.

...
docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-gcloud exited with "You do not currently have an active account selected. See https://cloud.google.com/sdk/docs/authorizing for more information.".')
[88740] Failed to execute script docker-compose

 

$ gcloud init

을 해서 구글 계정으로 로그인하고 my-docker 프로젝트를 만들어 주었습니다.

이제 docker-compose up을 하면 잘 실행됩니다.

$ docker-compose up                                                                                                       (membership-dev-context/default)
Creating network "my-docker_default" with the default driver
Creating my-docker_redis_1 ... done
Creating my-docker_web_1   ... done
Attaching to my-docker_redis_1, my-docker_web_1
redis_1  | 1:C 05 Mar 2021 11:50:53.962 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 05 Mar 2021 11:50:53.962 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 05 Mar 2021 11:50:53.962 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  | 1:M 05 Mar 2021 11:50:53.963 * monotonic clock: POSIX clock_gettime
redis_1  | 1:M 05 Mar 2021 11:50:53.963 * Running mode=standalone, port=6379.
redis_1  | 1:M 05 Mar 2021 11:50:53.963 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 05 Mar 2021 11:50:53.963 # Server initialized
redis_1  | 1:M 05 Mar 2021 11:50:53.964 * Ready to accept connections

 

 

기타 - exited with code 0 오류 삽질

web 서비스가 exited with code 0 오류로 종료되어 버리는 문제가 발생했었는데요.

$ docker-compose up
Building web
Step 1/1 : FROM python:3.7-alpine
3.7-alpine: Pulling from library/python
ba3557a56b15: Already exists
54b0d889b94a: Pull complete
67fda5bb5ea2: Pull complete
9a580d78cb73: Pull complete
2312b5a98cd3: Pull complete
Digest: sha256:e710c4e209d2d102dbf2e68ef3c08ae68c095af75ece1bf3a29a2b19f3bb5d39
Status: Downloaded newer image for python:3.7-alpine
 ---> 79d8d54b1857

Successfully built 79d8d54b1857
Successfully tagged my-docker_web:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating my-docker_web_1   ... done
Creating my-docker_redis_1 ... done
Attaching to my-docker_web_1, my-docker_redis_1
redis_1  | 1:C 05 Mar 2021 11:27:49.635 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1  | 1:C 05 Mar 2021 11:27:49.635 # Redis version=6.2.1, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1  | 1:C 05 Mar 2021 11:27:49.635 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis_1  | 1:M 05 Mar 2021 11:27:49.636 * monotonic clock: POSIX clock_gettime
redis_1  | 1:M 05 Mar 2021 11:27:49.636 * Running mode=standalone, port=6379.
redis_1  | 1:M 05 Mar 2021 11:27:49.636 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
redis_1  | 1:M 05 Mar 2021 11:27:49.636 # Server initialized
redis_1  | 1:M 05 Mar 2021 11:27:49.637 * Ready to accept connections
my-docker_web_1 exited with code 0

 

build: . 을 했어야 했는데 왜인지 build: composetest를 했었네요.

 

version: "3.9"
services:
  web:
    build: composetest
    ports:
      - "5000:5000"
  redis:
    image: "redis:alpine"

build가 안되어서 서버가 뜨지 않아서 바로 종료가 되었던 것입니다. 별 도움은 안되지만 서버가 구동되지 않더라도 서비스가 종료되지 않도록 하려면 tail -f 명령어를 걸어서 종료되지 않도록 붙잡아 두는 방법도 있습니다.

version: "3.9"
services:
  web:
    build: composetest
    ports:
      - "5000:5000"
    command: tail -f /dev/null
  redis:
    image: "redis:alpine"

 

반응형
0 Comments
댓글쓰기 폼