A month ago, we announced our configure-docker
command, and we're excited to announce an expansion of it that covers Docker Compose and other tools that leverage docker buildx build
!
Our latest release of the Depot CLI expands our new command that installs Depot as a Docker CLI plugin to configure a default buildx
driver to use Depot as well. Allowing you to leverage Depot for any workloads that use docker buildx build
, like Docker Compose. All without having to change a single line of code 🎉
How it works
First, you must install the latest version of the Depot CLI. See our CLI installation docs for more details.
Once you have the latest version of the CLI installed, you can run the following command:
Behind the scenes, in addition to installing Depot as a Docker CLI plugin, the command configures a default buildx
driver that routes builds to Depot. Allowing any docker buildx build
commands to use Depot, in addition to the existing docker build
command.
Using Depot with Docker Compose
Once the configure-docker
command is executed, you can use Depot with Docker Compose without changing a single line of code. All you need to do is ensure you have a Depot project configured for your build. You can do this via:
- Setting a
DEPOT_PROJECT_ID
environment variable to the project ID of the project you want to use for builds. - Running
depot init
in the root of the repository in which you're building your image. The command creates adepot.json
file that our plugin will detect.
If you have a Depot project configured, you can run docker compose build
, and Depot will build the images in your Docker compose file. You can see this in action in the following example.
Here is our example Docker compose file with a single service:
The Dockerfile that it is building looks like this:
Now, all you have to do is call build
or up
just as you usually would.
You can see that the Docker is building with Depot. It creates a separate build for each architecture and service defined in the compose.yml
.
If you want to use Depot with Docker Compose but prefer to use the up
command, you can also do that. Just run docker compose up
, and Depot will build your images.
Note on Docker Compose
Docker Compose creates a new build for each service and architecture defined in the compose.yml
. If you have a docker-compose.yml
that defines 3 services, and you're building for 2 architectures, you will have 6 builds created in Depot.
Power of Depot for all tools
We've got a lot of requests to integrate Depot with other developer tools out there that need to build containers on demand. Tools like Dev Containers and goreleaser
are great examples of this.
Before this command, these tools couldn't integrate with Depot. They call docker build
or docker buildx build
directly, and there was no way to configure them to use a different builder.
Now, with depot configure-docker
, all tools using Docker or buildx
internally can route their image builds to Depot. We have an integration guide and documentation for how this works with Dev Containers and docker build
and docker buildx build
in general.
We're excited about what this new command will unlock for folks! We will put out some new integration guides for other tools that need to build a Docker container on demand, so stay tuned for those. You can also hop in our Community Discord and let us know which tools you'd like us to integrate with next!