简体   繁体   English

构建 docker 映像以在 Docker Hub 上发布

[英]Build a docker image to publish on Docker Hub

I have a question about how Docker works.我有一个关于 Docker 如何工作的问题。 I currently have a project consisting of 3 services:我目前有一个由 3 项服务组成的项目:

  • Node (Frontend)节点(前端)
  • .NET Core WebApi (Backend) .NET Core WebApi(后端)
  • Redis (Cache) Redis(缓存)

I start these three projects through a docker-compose file.我通过一个 docker-compose 文件启动这三个项目。 I'm thinking of publishing this project as a Docker image on DockerHub so friends can run it without having to clone the project and install on your nas.我正在考虑将此项目发布为 DockerHub 上的 Docker 映像,以便朋友可以运行它而无需克隆项目并安装在您的 nas 上。 In my mind, I would just need to publish docker-compose and push it to DockerHub.在我看来,我只需要发布 docker-compose 并将其推送到 DockerHub。 So talking to another developer friend, he told me that I can't publish the docker image like that.因此,与另一位开发人员朋友交谈时,他告诉我不能像那样发布 docker 图像。 He said that I would have to create an image, enter the Linux image, put my 3 services and then publish it as a single image.他说我要创建一个镜像,输入Linux镜像,放上我的3个服务,然后发布为单个镜像。

Now I'm confused, I don't know much about docker.现在一头雾水,对docker了解不多。 I know that some images like WordPress already come with the entire environment configured (I don't know if it applies, but I imagine that PHP and Apache/Nginx must be configured).我知道像 WordPress 这样的一些图像已经配置了整个环境(我不知道它是否适用,但我想 PHP 和 Apache/Nginx 必须配置)。 I want to create a more straight ford image to make the configuration an easier step, just passing some parameters, and I think with docker-compose I can't achieve this, but I do know how to create a full docker image.我想创建一个更直接的福特图像以使配置更简单,只需传递一些参数,我认为使用 docker-compose 我无法实现这一点,但我知道如何创建完整的 docker 图像。

I see two options for solving that我看到解决这个问题的两种选择

  • The easiest way if you already know how docker compose works, you could upload every program individually to Docker Hub and then send the compose file to github or somewhere else, this way people wouldn't need to build, just run.如果您已经知道 docker 组合是如何工作的,那么最简单的方法是,您可以将每个程序单独上传到 Docker 集线器,然后将组合文件发送到 github,这样人们就需要以这种方式构建或在其他地方运行。

  • Another possibility is to "merge" containers, that's a little more complex but on the Dockerfile you could merge all the programs together to run in the same container instance.另一种可能性是“合并”容器,这有点复杂,但在 Dockerfile 上,您可以将所有程序合并在一起以在同一个容器实例中运行。 But for this you should need to research more on how to configure and inherit a container.但为此,您需要更多地研究如何配置和继承容器。

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

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