-
Before running something like: this: docker buildx create --name $MY_BUILD_NAME --platform $MY_BUILD_PLATFORMS --driver docker-container --use I would like to check whether or not a builder with that name already exists or not. Is there a way to do that? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
You can use the e.g. $ docker buildx inspect default
Name: default
Driver: docker
Nodes:
Name: default
Endpoint: desktop-linux
Status: running
Buildkit: 20.10.17
Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
$ buildx inspect non-existent
ERROR: no builder "non-existent" found If the builder cannot be found, then the return value of the command will a non-zero exit code. |
Beta Was this translation helpful? Give feedback.
-
A quicker option seems to be running
|
Beta Was this translation helpful? Give feedback.
-
``For a script as @treefern suggested, we would want to use an if condition. I believe that I have improved what @treefern suggested:
The improved script uses the exit status of the grep command, which is a more reliable and straightforward approach. Here's how it works: if docker buildx ls | grep -q sr-builder; then
echo "Builder exists"
else
echo "Builder does not exist"
fi
|
Beta Was this translation helpful? Give feedback.
-
Could you use the output status to short circuit the create command?
|
Beta Was this translation helpful? Give feedback.
You can use the
docker buildx inspect
command:e.g.
$ docker buildx inspect default Name: default Driver: docker Nodes: Name: default Endpoint: desktop-linux Status: running Buildkit: 20.10.17 Platforms: linux/amd64, linux/arm64, linux/riscv64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6 $ buildx inspect non-existent ERROR: no builder "non-existent" found
If the builder cannot be found, then the return value of the command will a non-zero exit code.