Why docker compose and not docker run? Is it in some way better? It feels like an excess technology to use when just simply running a single container.
The docker-compose approach means you only need to figure it out once. If you're going things like mounting volumes, opening ports, etc your docker run incantation can become complex.
Defining a docker-compose saves you time in the future ensuring all of your requirements are saved in your docker-compose.yml and you only have to run docker-compose up to get your server running.
Got you. I was curious to why docker created that compose file instead of just expecting the users to run docker run command. Your reply answered that question.
Arguably more containers will be added - so this is a trivial example.
But even for such a simple example, any startup params can be saved in that yml file for repeated usage, like volumes, select environment variables (this one container may not need everything in .env), port mappings, etc...
Before I learned Compose, I was writing shell scripts to maintain these values.
Plus, apparently this new Init tool writes the file for you, so why not?
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Why docker compose and not docker run? Is it in some way better? It feels like an excess technology to use when just simply running a single container.
The docker-compose approach means you only need to figure it out once. If you're going things like mounting volumes, opening ports, etc your docker run incantation can become complex.
Defining a docker-compose saves you time in the future ensuring all of your requirements are saved in your docker-compose.yml and you only have to run docker-compose up to get your server running.
Nice.
Got you. I was curious to why docker created that compose file instead of just expecting the users to run docker run command. Your reply answered that question.
I have a couple reasons:
Arguably more containers will be added - so this is a trivial example.
But even for such a simple example, any startup params can be saved in that yml file for repeated usage, like volumes, select environment variables (this one container may not need everything in .env), port mappings, etc...
Before I learned Compose, I was writing shell scripts to maintain these values.
Plus, apparently this new Init tool writes the file for you, so why not?