`DOCKER_AUTH_CONFIG` takes precedence over `docker login`
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- docker, gitlab, go
- 領域
- authentication, ci-cd, cli
調査の方向性
PR #6008 と、DOCKER_AUTH_CONFIG、docker login、docker push に関係する Docker CLI の認証パスを確認します。読み取り専用認証情報と書き込み認証情報を使って GitLab CI のシーケンスを再現し、その結果の動作が想定される認証情報の優先順位と一致すること、またはどの認証情報が使用されているかを明確に報告することを検証します。
索引モデルが issue の本文から書いたものです。
説明
Description
First of all, apologies if this is not the appropriate place to raise this — please feel free to redirect me if this should be handled elsewhere.
Context
Since the merge of PR #6008, we're experiencing issues when pushing to a private registry from a GitLab CI job using the docker:dind image.
Our GitLab CI pipelines pull images from a private registry using a read-only service account. To support this, we initialize the DOCKER_AUTH_CONFIG environment variable with a base64-encoded JSON config containing the read-only credentials (following the principle of least privilege). This is mandatory to allow the GitLab Runner to pull our job image.
Later in the pipeline, we perform a docker login with another service account that has write permissions, in order to push new images. The login correctly updates the ~/.docker/config.json file.
Issue
After the change introduced by this PR #6008, it seems that the DOCKER_AUTH_CONFIG environment variable continues to take precedence, even after a successful docker login. As a result, docker push fails with permission denied errors because it is still using the read-only credentials from DOCKER_AUTH_CONFIG.
Furthermore, there is no message or warning from the Docker CLI indicating that DOCKER_AUTH_CONFIG is being used in preference to the updated login credentials. This makes it especially difficult to diagnose the root cause, as one would expect the docker login command to override or be honored for subsequent operations.
Previously, docker login would override the current auth context, allowing the push to succeed using the updated credentials.
Maybe I misunderstood this change and we could do otherwise? Or maybe this is a bug introduced with this PR. Thanks for your help.
Reproduce
- Use
docker:dindin GitLab CI. - Set
DOCKER_AUTH_CONFIGwith read-only credentials to access a private registry. - Run
docker login private-registry.xxx.comwith credentials that have write access. - Attempt to run
docker push private-registry.xxx.com/repo/image:tag.
unauthorized: unauthorized to access repository: repo/image, action: push: unauthorized to access repository: repo/image, action: push
Expected behavior
docker push should succeed using the credentials updated via docker login.
docker version
Client:
Version: 28.3.0
Context: default
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.25.0
Path: /usr/local/libexec/docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.37.3
Path: /usr/local/libexec/docker/cli-plugins/docker-compose
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 1
Server Version: 28.3.0
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
runc version: v1.2.6-0-ge89a299
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.16.14-1.el8.elrepo.x86_64
Operating System: Alpine Linux v3.22 (containerized)
OSType: linux
Architecture: x86_64
CPUs: 32
Total Memory: 125.8GiB
Name: eae77d15590e
ID: 024926f0-57c7-4049-b2a5-c3e33d4dca88
Docker Root Dir: /var/lib/docker
Debug Mode: false
Experimental: false
Additional Info
No response
- 主要言語
- Go
- スター
- 6.1k
- フォーク
- 2.2k
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 47
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
docker/cli のほかの issue
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
kind/feature status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
kind/bug status/0-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
acceptance-tests phase-coding schema-coverage testing triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100