Docker

將帶有兩個標籤的圖像推送到 gcr.io 會產生兩個不同的圖像

  • June 29, 2021

我正在執行以下操作:

docker build -t gcr.io/projid/imgname:333 -t gcr.io/projid/imgname:latest。

docker login -u _json_key -p “$(cat /secrets/service-account.json)” https://gcr.io

碼頭工人推gcr.io/projid/imgname:333

docker push gcr.io/projid/imgname:latest

第一個推送命令的輸出:

Pushing to google container registry ...
The push refers to a repository [gcr.io/projid/imgname]
24af4f7c7118: Preparing
17b0972980d8: Preparing
6d6a6425aacb: Preparing
809c8c0dd73c: Preparing
e8d45b8ab3ca: Preparing
e8fa134cb7b8: Preparing
7cbcbac42c44: Preparing
e8fa134cb7b8: Waiting
7cbcbac42c44: Waiting
809c8c0dd73c: Layer already exists
e8d45b8ab3ca: Layer already exists
7cbcbac42c44: Layer already exists
e8fa134cb7b8: Layer already exists
17b0972980d8: Pushed
24af4f7c7118: Pushed
6d6a6425aacb: Pushed
333: digest: sha256:dae8cf914ba49928e6f0a34f6740802403813e6d10aa1c1d448a62ce9bb69066 size: 1779

第二個推送命令的輸出:

Pushing to google container registry ...
The push refers to a repository [gcr.io/projid/imgname]
24af4f7c7118: Preparing
17b0972980d8: Preparing
6d6a6425aacb: Preparing
809c8c0dd73c: Preparing
e8d45b8ab3ca: Preparing
e8fa134cb7b8: Preparing
7cbcbac42c44: Preparing
e8fa134cb7b8: Waiting
7cbcbac42c44: Waiting
e8d45b8ab3ca: Layer already exists
809c8c0dd73c: Layer already exists
24af4f7c7118: Layer already exists
17b0972980d8: Layer already exists
6d6a6425aacb: Layer already exists
7cbcbac42c44: Layer already exists
e8fa134cb7b8: Layer already exists
latest: digest: sha256:4f57375919829982741d095f8917306fe0c1410e115d030179bae4b8e4299c30 size: 1742

問題:為什麼帶有兩個標籤的同一個圖像會在Google容器系統資料庫中產生兩個不同的圖像?

您肯定在推送兩個圖像標籤。我建議使用單個標籤建構,然後添加第二個標籤並一一推送圖像標籤。如果第二個添加新摘要是 GCR 錯誤。我遇到了這個錯誤並通過刪除儲存庫來解決,以便在下一次推送時重新創建它。在我的配置中,Docker 版本也是一個因素。版本 17.04.0-ce,建構 4845c56 會觸發額外的摘要,而版本 17.03.1-ce,建構 c6d412e 可以正常工作。

更新:2021 年 5 月

我沒有收到這個問題,所以我相信它已經修復:

Already have image (with digest): gcr.io/cloud-builders/docker
The push refers to repository [gcr.io/proj-dev/client]
1b046f5a4242: Preparing
45ad1ef5106f: Preparing
02c95cff5c48: Preparing
4d5085b7c406: Preparing
516e4ad96ca6: Preparing
94ed6f39e7b4: Preparing
e73bffd94869: Preparing
ebf12965380b: Preparing
94ed6f39e7b4: Waiting
e73bffd94869: Waiting
ebf12965380b: Waiting
516e4ad96ca6: Pushed
4d5085b7c406: Pushed
e73bffd94869: Layer already exists
ebf12965380b: Layer already exists
1b046f5a4242: Pushed
45ad1ef5106f: Pushed
94ed6f39e7b4: Pushed
02c95cff5c48: Pushed
latest: digest: sha256:f824ee7aecb79e1826a311d4dd0d85919a636abc7defc165ec36e8ceb330829c size: 1999
The push refers to repository [gcr.io/proj-dev/client]
1b046f5a4242: Preparing
45ad1ef5106f: Preparing
02c95cff5c48: Preparing
4d5085b7c406: Preparing
516e4ad96ca6: Preparing
94ed6f39e7b4: Preparing
e73bffd94869: Preparing
ebf12965380b: Preparing
94ed6f39e7b4: Waiting
e73bffd94869: Waiting
ebf12965380b: Waiting
1b046f5a4242: Layer already exists
02c95cff5c48: Layer already exists
4d5085b7c406: Layer already exists
45ad1ef5106f: Layer already exists
516e4ad96ca6: Layer already exists
e73bffd94869: Layer already exists
ebf12965380b: Layer already exists
94ed6f39e7b4: Layer already exists
3.0.0-master-7e0d787: digest: sha256:f824ee7aecb79e1826a311d4dd0d85919a636abc7defc165ec36e8ceb330829c size: 1999

引用自:https://serverfault.com/questions/828208