Hi! quick question: is it possible to dynamically change the image’s arch based on the host’s machine instead of create 2 separate docker compose file?
The only difference here is the image, and ideally running them e.g. docker compose up -d then let the engine decide which arch is appropriate in the host’s machine instead of using docker compose -f <FILE> up -d.
#!/bin/bash
ARCH=$(uname -m)
if [ -z "$ARCH" ]; then
echo "Error: Unable to determine architecture"
exit 1
fi
if [ "$ARCH" = "arm64" ]; then
export TYPESENSE_IMAGE=${TYPESENSE_IMAGE:-"docker.io/typesense/typesense:0.25.2-arm64"}
else
export TYPESENSE_IMAGE=${TYPESENSE_IMAGE:-"docker.io/typesense/typesense:0.25.2"}
fi
docker-compose up -d
I’m confused @conradwt (please enlighten me), how will this translate to docker compose? I’m not using a dockerfile for this specific problem. What I’m after here is that the official typesense image will use the appropriate arch based on the host machine, ideally I can docker compose up -d without telling it what arch is on.
@jaeyson The image that you’re using is already a multi-platform image. For example, it supports both linux/amd64 and linux/arm64.
Next, when you perform docker compose up -d, it will pull the image and run the appropriate platform variant for your host architecture without having to specify the platform. BTW, this is mentioned at the top of the page of the documentation link I sent in the previous post.
Finally, you can check the ‘Architecture’ and ‘Os’ of the running Docker image or container by doing the following:
There’s no platform option for docker compose. Thus, what you’re looking for here is something even easier. For example, you’ll want to do the following: