Start Only Dependencies via Docker Compose

Docker Compose is great, among other things, for demoing your web applications. It allows you to have consistent runtime environment, download dependencies without polluting the host system and automatically start external services like databases, search engines, mail servers, message queues, caches, etc. Many projects put docker-compose.yml configuration file in the source repository root, to be able to start the app by just typing:

However, during development, when you are constantly changing and debugging the code, it’s sometimes useful to keep the app running natively outside of Docker, but still running dependencies via Docker. This can be achieved in the same docker-compose.yml file by adding a special deps service (or however you want to call it) that will just start the dependencies and exit. It can be invoked as follows:

I am using this technique in my Puffin project – see my docker-compose.yml for an example.

Edit: I have changed how it’s done in Puffin, since I needed more configuration options. I linked above the original file.

Leave a Reply

Your email address will not be published.