by It makes it easy to: The vision is that someone writes a docker-compose.yml that specifies everything that’s needed in development and commits it to their repo.
A typical pattern for production Dockerfiles is to reduce the number of layers by chaining single commands into one RUN statement.
Your production Dockerfile might look like this: This is terrible for development because every time that command is re-run, Docker will re-download all of your dependencies and reinstall them.
In Docker Compose, you can simply add this cached keyword to your volume mounts to get a significant performance guarantee.