VAIBHAV JAIN
VAIBHAV JAIN

Reputation: 19

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

Upvotes: 0

Views: 668

Answers (1)

Guilherme Maia
Guilherme Maia

Reputation: 161

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.

Upvotes: 1

Related Questions