我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
具体将映像推到私有repo的确切语法是什么?
我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
具体将映像推到私有repo的确切语法是什么?
当前回答
以下是将Docker Image推送到DockerHub的私有存储库的步骤
1-首先使用命令检查Docker图像
码头工人的图片
2-查看Docker Tag命令帮助
Docker标签——救命
3-现在标记一个名称,以您创建的图像
DockerHubUser\Private-repoName:tagName(标签名可选。默认名称为最新)
4-在推送镜像到DockerHub Private Repo之前,请先使用命令登录DockerHub
docker login[提供dockerHub用户名和密码登录]
5-现在推Docker映像到您的私人回购使用命令
docker push [options] ImgName[:tag]例如docker push DockerHubUser\Private-repoName:tagName
6-现在导航到DockerHub Private Repo,你会看到Docker映像被推送到你的私有存储库上,在前面的步骤中名称写为TagName
其他回答
首先登录您的私有存储库。
> 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命令参考
在dockerhub上创建存储库:
$docker tag IMAGE_ID用户名ondockerhub /repoNameOnDockerhub:最新
$docker push UsernameOnDockerhub/repoNameOnDockerhub:最新
注:此处 "repoNameOnDockerhub":您所提到的名称的存储库已经存在 呈现在dockerhub上
"latest":只是标签
裁判:dock.docker.com
介绍部署和配置注册表的基本信息
运行本地注册表
在部署注册表之前,需要在主机上安装Docker。
使用如下命令启动注册表容器:
start_registry.sh
#!/bin/bash
docker run -d \
-p 5000:5000 \
--restart=always \
--name registry \
-v /data/registry:/var/lib/registry \
registry:2
从Docker Hub复制一个映像到注册表
Pull the ubuntu:16.04 image from Docker Hub. $ docker pull ubuntu:16.04 Tag the image as localhost:5000/my-ubuntu. This creates an additional tag for the existing image. When the first part of the tag is a hostname and port, Docker interprets this as the location of a registry, when pushing. $ docker tag ubuntu:16.04 localhost:5000/my-ubuntu Push the image to the local registry running at localhost:5000: $ docker push localhost:5000/my-ubuntu Remove the locally-cached images. This does not remove the localhost:5000/my-ubuntu image from your registry. $ docker image remove ubuntu:16.04 $ docker image remove localhost:5000/my-ubuntu Pull the localhost:5000/my-ubuntu image from your local registry. $ docker pull localhost:5000/my-ubuntu
Deploy a plain HTTP registry根据docs.docker.com,这是非常不安全的,不建议。
Edit the daemon.json file, whose default location is /etc/docker/daemon.json on Linux or C:\ProgramData\docker\config\daemon.json on Windows Server. If you use Docker for Mac or Docker for Windows, click Docker icon -> Preferences -> Daemon, add in the insecure registry. If the daemon.json file does not exist, create it. Assuming there are no other settings in the file, it should have the following contents: { "insecure-registries" : ["myregistrydomain.com:5000"] } With insecure registries enabled, Docker goes through the following steps: First, try using HTTPS. If HTTPS is available but the certificate is invalid, ignore the error about the certificate. If HTTPS is not available, fall back to HTTP. Restart Docker for the changes to take effect.
dockerhub中还有一个“默认隐私”设置。访问https://hub.docker.com/settings/default-privacy或点击帐户设置->默认隐私。
将切换设置为“private”。
这不是一个完整的解决方案,但至少默认的私有比默认的公共要好。你可以返回并公开你想要的。
当推送到Docker Hub帐户时,无论是公共帐户还是私有帐户,过程都是相同的。
警察说:
我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
直接的问题是私有回购(me-private)似乎与映像(my-image)具有不同的名称。repo和映像必须具有相同的名称(减去任何标记)。
TLDR; 一个名为my-image或my-image:标签的图像必须有一个my-image的回收名。
因为行动中心的回购被命名为我私人的, Docker Hub不会将它们视为相同的,并将创建名为my-image的新回购。
(默认情况下,新的回购将是公开的,除非您更改设置使所有存储库都是私有的。)
截至2022年6月,建立Docker Hub回购的流程是:
给定以下值:
用户名= yourusername 图像名称=图像 标签=标签
1)标记(或提交)本地图像,添加一个前缀与您的用户名:
docker tag theimage:thetag yourusername/theimage:thetag
注:
如果你在一个组织中,你需要双前缀的图像-像这样:
docker tag theimage:thetag yourusername/yourorganizationname/theimage:thetag
如果你的标签是最新的,:标签部分可以省略;Docker假设:latest如果你没有输入:thetag部分
2)将前缀图像推送到Docker Hub:
docker push yourusername/theimage:thetag
OR
docker push yourusername/yourorganizationname/theimage:thetag
对于私人回购,这些额外步骤之一是必要的:
要么
在上述第1步之前,在Docker Hub帐户中创建一个私有存储库
请记住,存储库名称必须与您计划推送的映像相同。不要在存储库名称中包含thetag部分。例如,如果你的映像是ubuntu:14.04,你可以将你的存储库命名为ubuntu。(所有带标签的图片,如ubuntu:latest, ubuntu:14.04等,都将进入ubuntu repo。)
Or
如果你没有提前创建存储库(这不是必需的!):转到Docker Hub中的帐户;点击新推出的回购,然后它的设置选项卡-并使你的回购私有。