1

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?

Currently I have 2 files:

For arm64 (osx)

services:
  typesense:
    image: docker.io/typesense/typesense:0.25.2-arm64
    container_name: typesense
    restart: on-failure
    ports:
      - "8108:8108"
    volumes:
      - ./typesense-data:/data
    command: '--data-dir /data --api-key=xyz --enable-cors'

For non arm64

services:
  typesense:
    image: docker.io/typesense/typesense:0.25.2
    container_name: typesense
    restart: on-failure
    ports:
      - "8108:8108"
    volumes:
      - ./typesense-data:/data
    command: '--data-dir /data --api-key=xyz --enable-cors'

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.

1 Answer 1

1

The standard practice is to build multi-platform image under the same name and tag. It would have common manifest, then the machine would resolve the platform based on its architecture.

The technique how to build those depends on your CI, but see here for example - https://docs.docker.com/build/building/multi-platform/ for a basic case.

Also see our GitHub Action here for reference how you can build for different architectures and then connect via manifest - https://github.com/relizaio/reliza-docker-action/blob/master/action.yaml (lines 150-162).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.