简体   繁体   English

自动推送到Docker私有注册表

[英]Automatic push to a Docker private registry

I've set up a Docker private registry and I need to push images to this one from a script that is triggered on each successfull build (build is done with Drone from a dedicated build container). 我已经设置了一个Docker私有注册表,我需要将脚本从每次成功构建触发的脚本推送到该镜像(通过专用构建容器中的Drone完成构建)。

When I issue a 'docker push', I first need to authentify to be able to push to the registry. 当我发出“ docker push”命令时,我首先需要进行身份验证以能够推送到注册表。

Is there any setup I could use to keep the credential somewhere and use it within the script ? 我可以使用任何设置将凭据保存在某个地方并在脚本中使用它吗?

The way I envisioned it was to just run the command in my scripts to authenticate to docker before you push the image: 我设想的方式是在推送映像之前在脚本中运行命令以对Docker进行身份验证:

docker login –u <your_username> –p <your_password> <your_docker_registry_fqdn>

I think it is easier to maintain the script should you have a change in the username or password or have multiple users, no need to download another credentials file which you will have to manually generate with the new password or username. 我认为,如果您更改了用户名或密码或有多个用户,则更容易维护脚本,而无需下载其他凭据文件,而必须使用新的密码或用户名手动生成该凭据文件。

I've found that .dockercfg was used to keep the credential and the address of the registry. 我发现.dockercfg用于保留凭据和注册表地址。
Setting this .dockercfg in the $HOME dir fixed the thing. 在$ HOME目录中设置此.dockercfg可以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM