Is it possible to run docker compose from a docker pipeline?
The docker runner does not play nice with docker-compose due to the fact that it uses docker-in-docker, and because docker pipelines have features (like services) which directly compete with docker-compose. If you require docker-compose you may consider an alternate runner, such as the exec runner.
- host drone yourself,
- use the docker-runner and
- don’t mind security concerns due to running trusted pipelines,
you can bind mount the local docker socket and just use any image, that is capable of running docker-compose on the machine, the runner is on.
This works, but you will still hit some limitations. The containers spawned with docker-compose will be attached to a separate network and won’t be reachable from inside your pipeline. Also, mounting volumes won’t work as expected because docker-compose volumes are mounted on the host machine; most people using docker-compose want to mount volumes “inside” their pipelines as opposed to on the host machine.
For these reasons (and others) we do not consider this a supported operation when using the Docker runner and recommend choosing another runner, such as the exec runner.
Good points. Also worth noting, drone won’t cleanup anything for you, so you have to make sure, it’s done properly in the pipeline (docker-compose down -v), even though former steps may have failed.