Set a builder as default for the current context
In the previous step, we learned how to switch to a specific builder instance for the current session. In this step, we will learn how to set a builder instance as the default for the current Docker context. This means that whenever you use Docker commands within this context, the specified builder will be used automatically.
To set a builder as the default for the current context, you use the docker buildx use
command with the --default
flag, followed by the name of the builder instance.
Let's set mybuilder1
as the default builder for the current context.
docker buildx use --default mybuilder1
After executing this command, mybuilder1
will be the default builder for this context.
You can verify this by listing the builder instances. The default builder will be marked with an asterisk (*
) and also indicated as default
in the output.
docker buildx ls
You should see mybuilder1
marked as both the active builder (with *
) and the default builder.
Now, let's set mybuilder2
as the default builder.
docker buildx use --default mybuilder2
Verify that mybuilder2
is now the default builder.
docker buildx ls
You should see mybuilder2
marked as both active and default.
Setting a default builder is useful when you consistently want to use a specific builder for your projects within a particular Docker context.