简体   繁体   English

从 docker 文件触发 docker 组合文件的最佳方法是什么?

[英]What is the best way to trigger a docker compose file from docker file?

I am learning about docker recently so not clear on this part, suppose I am making a node js app where a frontend is been connected to mongo db, but I use a docker-compose file to spin up the mongo container every time I do development, now I have completely build my application and want to make a final docker file for it so that I can publish my image.我最近正在学习 docker,所以这部分不清楚,假设我正在制作一个节点 js 应用程序,其中前端已连接到 mongo db,但我使用 docker-compose 文件来启动 mongo 容器,每次我进行开发时,现在我已经完全构建了我的应用程序,并想为其制作最终的 docker 文件,以便我可以发布我的图像。 What is the best way to do this?做这个的最好方式是什么?

Idea -1想法-1

Should I wrap up my docker-compose file also in the final image so that from dockerfile before triggering the app using npm start I should use trigger this docker-compose file我是否应该将我的 docker-compose 文件也包含在最终图像中,以便在使用npm start我应该使用触发器这个 ZBAEDB53E8045AE7AE79Z39

Or is there any other way in which i can directly spin up the container或者有没有其他方法可以直接启动容器

I'm not a Docker/Compose expert either, but you usually reference your Dockerfile from docker-compose.yml , and not the other way around.我也不是 Docker/Compose 专家,但您通常从docker-compose.yml 引用您的 Dockerfile 而不是相反。

It'd be very helpful if you could share an example of your docker-compose.yml and expand on your deployment plan (local shell script? CI/CD on cloud? single host for all your services?).如果您可以分享 docker-compose.yml 的示例并扩展您的部署计划(本地 shell 脚本?云上的 CI/CD?所有服务的单一主机?),将会非常有帮助。

Also, I encourage you to checkout the official Use Compose in production .另外,我鼓励您查看官方的Use Compose in production

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

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