简体   繁体   中英

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. What is the best way to do this?

Idea -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

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.

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?).

Also, I encourage you to checkout the official Use Compose in production .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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