我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
具体将映像推到私有repo的确切语法是什么?
我有一个标记为me/my-image的docker映像,我在dockerhub上有一个命名为me-private的私有repo。 当我推行我自己/我的形象时,我最终总是撞上公共回购。
具体将映像推到私有repo的确切语法是什么?
当前回答
裁判: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”。
这不是一个完整的解决方案,但至少默认的私有比默认的公共要好。你可以返回并公开你想要的。
有两种选择:
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.
只需简单的三步:
Docker登录——username用户名 如果你省略了——password,提示输入密码,这是推荐的,因为它不会存储在你的命令历史中 Docker标签my-image用户名/my-repo Docker推送用户名/my-repo
如果你的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
裁判: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.