简体   繁体   English

我是否必须使用私有Docker注册表将我的源代码保持私有状态?

[英]Must I use a private Docker registry to keep my source private?

I've just started playing around with Docker recently and wondered if I don't plan to make my code public, does that mean I will have to pay for a private Docker registry? 我最近才刚开始使用Docker,并且想知道是否不打算公开我的代码,这是否意味着我将需要为私有Docker注册中心付费?

The reason I'm asking is because it seems like, from the tutorials I'm following, when deploying my container to production, I will have to somehow pull it from the Docker registry. 我问的原因是,从我关注的教程看来,当将容器部署到生产环境时,我将不得不以某种方式将其从Docker注册表中拉出。 Unless I can push a container directly from my local computer to production, I've to first push my container to the public Docker registry. 除非我可以直接从本地计算机将容器推送到生产环境,否则必须首先将容器推送到公共Docker注册表。 However, my container often already have a copy of my source which was copied from the volume on my dev machine. 但是,我的容器通常已经有我的源的副本,该副本是从我的开发机上的卷中复制的。 So I may not want to make every source code public on the registry. 因此,我可能不想在注册表上公开每个源代码。

In this sense, does it mean I'll definitely have to pay to use Docker if I don't wish to make my source code public? 从这个意义上说,这是否意味着如果我不希望公开我的源代码,我肯定需要付费使用Docker吗? Can I push a container directly from my local computer to a production server without going through Docker registry? 是否可以不通过Docker注册表将容器直接从本地计算机推送到生产服务器? Or am I using Docker the wrong way? 还是我以错误的方式使用Docker?

You don't need to push the image to a public registry such as Dockerhub. 您无需将映像推送到Dockerhub等公共注册表。 You can deploy you own docker registry (which is it self packaged in a docker container) and use that private registry to push and pull images. 您可以部署自己的Docker注册表(将其自身打包在Docker容器中),然后使用该私有注册表来推送和拉取映像。

The deployment process for the registry can be found in the official docs . 注册表的部署过程可以在官方文档中找到。

Alternatively, you can package your image as a tar ball, upload the tarball to production server, import the tarball back to a docker image and start the container. 或者,您可以将映像打包为tar球,将tarball上载到生产服务器,再将tarball导入到docker映像中并启动容器。

docker save --output image.tar IMAGE // save the image into a tar ball
docker import image.tar IMAGE // on another server, import the image back from tar.

You can set up your own "private" docker registry and dont't have to pay. 您可以设置自己的“私有” Docker注册表,而不必付费。 Here is a good tutorial for this solution: Setting up a private docker registry. 这是此解决方案的一个很好的教程: 设置私有Docker注册表。

Little Overview of the steps: 小步骤概述:

  1. Run the Docker Registry Image (registry:2) 运行Docker Registry Image(registry:2)
  2. Create a Self Signed Certificate 创建自签名证书
  3. Run the Private Docker Registry with TLS 使用TLS运行私有Docker注册表
  4. Access the Remote Registry form a local Client 从本地客户端访问远程注册表

Now you can pull and push your images to the private registry. 现在,您可以将映像拉入专用注册表。

For most languages (except for maybe bash and other scripts :) ) you don't have to add your source code but only the binaries. 对于大多数语言(也许bash和其他脚本:)除外),您不必添加源代码,而只需添加二进制文件。

Other than that you can store your images locally / on a usb stick with docker export or docker save. 除此之外,您还可以使用docker export或docker save在本地/ usb棒上存储图像。

But if you want to pull images from the internet you either go public or have to have a private registry. 但是,如果您想从互联网上提取图像,则要么公开,要么必须拥有一个私有注册表。

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

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