Is it good practice to run several applications in one container? Why or why not?
No. One container should run one application (one concern); multiple cooperating containers are connected with networks and Compose instead.
Containers are designed around a single main process (PID 1 in the container). Packing a web server, a database and a cron job into one container throws away what makes containers useful:
- Lifecycle. Docker monitors and restarts the main process. If it is a supervisor juggling three apps, a crashed database goes unnoticed while the container looks healthy.
- Scaling and updates. You can't scale the web tier without also copying the database, or update one part without rebuilding and restarting the whole bundle.
- Maintainability. Each image stays small, with one set of dependencies and one log stream (
docker logs). - Security. A smaller image has a smaller attack surface, and a compromise of one component does not hand over the others.
Bundling everything into one box would amount to building a VM out of a container, giving up the advantages without gaining a VM's stronger isolation. When applications need to talk to each other (web server and database), they run in separate containers joined by a Docker network, typically defined together in a Docker Compose file.
Go deeper:
Docker Docs: Run multiple processes in a container — why one service per container is the norm, and the workarounds if you must.
Docker Docs: Building best practices — "decouple applications" and the other image-design rules.