Hi everyone,
I am currently learning Docker and containerized development for the first time. I am working on a small multi-service project using Docker Compose (for example: API service, frontend service, database, and nginx).
My biggest difficulty so far is understanding how dependencies should be managed in Docker-based projects.
Each service has its own Dockerfile and sometimes its own dependency file (for example requirements.txt for Python services). However, I often encounter issues where the container fails to start because a dependency is missing or because of a version conflict between packages.
For example, sometimes I see errors like:
ModuleNotFoundError: No module named 'something'
or version-related issues caused by indirect dependencies that were installed automatically.
What confuses me is:
- How do developers usually decide which dependencies should be explicitly listed in files like
requirements.txt? - Should we only list the packages we directly import in the code, or also include their indirect dependencies?
- What is the typical workflow professionals use to debug dependency issues inside Docker containers?
- In larger Docker Compose setups with multiple services, how do teams usually keep dependencies organized and avoid conflicts?
Since I am new to Docker and containerized development, I would really appreciate any advice or best practices used in real-world projects.
Thank you!