我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
具体将映像推到私有repo的确切语法是什么?
我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
具体将映像推到私有repo的确切语法是什么?
当前回答
dockerhub中还有一个“默认隐私”设置。访问https://hub.docker.com/settings/default-privacy或点击帐户设置->默认隐私。
将切换设置为“private”。
这不是一个完整的解决方案,但至少默认的私有比默认的公共要好。你可以返回并公开你想要的。
其他回答
如果你的docker注册表是私有和自托管的,你应该做以下事情:
docker login <REGISTRY_HOST>:<REGISTRY_PORT>
docker tag <IMAGE_ID> <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>
docker push <REGISTRY_HOST>:<REGISTRY_PORT>/<APPNAME>:<APPVERSION>
例子:
docker login repo.company.com:3456
docker tag 19fcc4aa71ba repo.company.com:3456/myapp:0.1
docker push repo.company.com:3456/myapp:0.1
首先,你需要用你的注册主机正确地标记你的图像:
docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
然后docker push使用相同的标签。
docker push NAME[:TAG]
例子:
docker tag 518a41981a6a myRegistry.com/myImage
docker push myRegistry.com/myImage
如果有人正在寻找一种快速将所有图像推送到私有存储库的方法, 你可以使用我的bash脚本-它会将所有Docker映像推送到新的私有注册表:
#!/bin/bash
repo="<change_to_your_new_repo>"
remote_repo="<the_new_repo_name>"
for img in $(docker images --format "{{.Repository}}:{{.Tag}}")
do
image=$(echo $img | cut -d ":" -f 1)
image_tag=$(echo $img | cut -d ":" -f 2)
docker image tag $image:$image_tag $repo/$remote_repo/$image:$image_tag
docker image push $repo/$remote_repo/$image:$image_tag
docker rmi $repo/$remote_repo/$image:$image_tag
done
在dockerhub上创建存储库:
$docker tag IMAGE_ID用户名ondockerhub /repoNameOnDockerhub:最新
$docker push UsernameOnDockerhub/repoNameOnDockerhub:最新
注:此处 "repoNameOnDockerhub":您所提到的名称的存储库已经存在 呈现在dockerhub上
"latest":只是标签
在本地拉一个图像后,你可以做下面的事情:
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
然后docker push使用相同的标签。
docker push NAME[:TAG]
例子:
docker tag gvenzl/oracle-xe:21-slim quay.io/repository/yourDirectory/oracle_xe:oracle-xe
docker push quay.io/repository/yourDirectory/oracle_xe:oracle-xe