我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。

具体将映像推到私有repo的确切语法是什么?


当前回答

在dockerhub上创建存储库:

$docker tag IMAGE_ID用户名ondockerhub /repoNameOnDockerhub:最新

$docker push UsernameOnDockerhub/repoNameOnDockerhub:最新

注:此处 "repoNameOnDockerhub":您所提到的名称的存储库已经存在 呈现在dockerhub上

"latest":只是标签

其他回答

首先登录您的私有存储库。

> docker login [OPTIONS] [SERVER]

[OPTIONS]: 
-u username 
-p password

eg:

> docker login localhost:8080

然后为您的私有存储库标记您的映像

> docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]

eg:

> docker tag myApp:v1 localhost:8080/myname/myApp:v1

最后将您的标记图像推到您的私有存储库

>docker push [OPTIONS] NAME[:TAG]

eg:

> docker push localhost:8080/myname/myApp:v1

参考

Docker命令参考

有两种选择:

Go into the hub, and create the repository first, and mark it as private. Then when you push to that repo, it will be private. This is the most common approach. log into your docker hub account, and go to your global settings. There is a setting that allows you to set what your default visability is for the repositories that you push. By default it is set to public, but if you change it to private, all of your repositories that you push will be marked as private by default. It is important to note that you will need to have enough private repos available on your account, or else the repo will be locked until you upgrade your plan.

在dockerhub上创建存储库:

$docker tag IMAGE_ID用户名ondockerhub /repoNameOnDockerhub:最新

$docker push UsernameOnDockerhub/repoNameOnDockerhub:最新

注:此处 "repoNameOnDockerhub":您所提到的名称的存储库已经存在 呈现在dockerhub上

"latest":只是标签

首先,你需要用你的注册主机正确地标记你的图像:

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

dockerhub中还有一个“默认隐私”设置。访问https://hub.docker.com/settings/default-privacy或点击帐户设置->默认隐私。

将切换设置为“private”。

这不是一个完整的解决方案,但至少默认的私有比默认的公共要好。你可以返回并公开你想要的。