I'm brand new to Docker so I'm sorry if any of this sounds dumb. I've done a bunch of research on this topic but finding hard to understand what the best practice is. For context, I want to start a new Django project and wanted to incorporate Docker since I've never done it before. To start I think I would want one container for the app and one for a postgres database. It seems there are few paths I could go down but not sure the most optimal one:
docker-compose up -d
to start the app and db containers and then attach to the app container and develop in a remote VS Code instance? I also know about Dev Containers, but I also don't understand how dev containers work when I want to work with a database or just other containers in general.So I guess my main question is which of these is the smartest thing to do?
And if it is using a Dev Container, how do I work with a database? Do I have the database in the same Dev container or is it in a separate non-dev container or something?
When developing a project (especially a web application) it is easy to be tempted to create a Docker development environment (i.e. a "dockerized" version of your project but for development), because in the first instance it sounds very convenient to:
However, involving Docker in the development of a project can also introduce complexities:
You can use Docker in development without necessarily introducing these complexities, for example, by "dockerizing" certain parts of the project (like the example given by David Maze, where only PostgreSQL runs with Docker), but if you want to "dockerize" the whole project for development, you must have good reasons to do so, for example:
In conclusion, option 1 is the recommended option in most cases, besides, it is best to just be flexible and have good reasons to do things, because at the end of the day the technology should work for us and not us for it.