我目前正在運行註冊表碼頭容器和ngnix碼頭容器,類似於this setup以保護我的私人碼頭註冊表。我正在運行Jenkins,以便在Docker容器中自動構建我的應用程序,然後將容器推送到我的私人碼頭註冊表。使用憑證將圖像推送到私人碼頭註冊表
問題出在我需要推送圖像時。詹金斯(在一個容器中同時運行)執行包含以下步驟的shell腳本:
sudo docker run hello-world
sudo docker tag -f hello-world localhost:5000/hello:latest
sudo docker login -u username -p pass -e [email protected] localhost:5000/
sudo docker search localhost:5000/
sudo docker push localhost:5000/hello:latest
然後構建失敗,出現以下的輸出:
Building in workspace /var/jenkins_home/jobs/HelloWorld/workspace [workspace] $ /bin/sh -xe /tmp/hudson6027890842360704977.sh
+ sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
registry latest e255d21840f8 2 days ago 422.9 MB
jenkins latest fc39417bd5fb 13 days ago 708.2 MB
nginx latest 407195ab8b07 2 weeks ago 133.9 MB
localhost:5000/hello latest 0a6ba66e537a 3 months ago 960 B hello-world latest 0a6ba66e537a 3 months ago 960 B
+ sudo docker run hello-world
Hello from Docker. This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker Hub account: https://hub.docker.com
For more examples and ideas, visit: https://docs.docker.com/userguide/
+ sudo docker tag -f hello-world localhost:5000/hello:latest
+ sudo docker login -u username -p pass -e [email protected] localhost:5000/
WARNING: login credentials saved in /root/.docker/config.json Login Succeeded
+ sudo docker search localhost:5000/
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
library/hello 0
+ sudo docker push localhost:5000/hello:latest
The push refers to a repository [localhost:5000/hello] (len: 1)
Sending image list Pushing repository localhost:5000/hello (1 tags)
b901d36b6f2f: Pushing
Please login prior to push:
Username (username): EOF
Build step 'Execute shell' marked build as failure
Finished: FAILURE
換句話說,我能跑標記hello-world容器。我可以登錄到我的私人註冊表並搜索它。但是,如果我想推送自己的圖像,則需要再次進行驗證。
希望有人知道一個簡單的解決方案,到目前爲止我找不到自己的一個。我運行碼頭版本1.9.1,在Ubuntu 14.04.3 LTS上構建a34a1d5。
即使您沒有https,也可能適用:https://github.com/docker/distribution/issues/719#issuecomment-157213022 – VonC