<p>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.</p>
<p>The technique how to build those depends on your CI, but see here for example - <a href="https://docs.docker.com/build/building/multi-platform/" rel="nofollow noreferrer">https://docs.docker.com/build/building/multi-platform/</a> for a basic case.</p>
<p>Also see our GitHub Action here for reference how you can build for different architectures and then connect via manifest - <a href="https://github.com/relizaio/reliza-docker-action/blob/master/action.yaml" rel="nofollow noreferrer">https://github.com/relizaio/reliza-docker-action/blob/master/action.yaml</a> (lines 150-162).</p>

CC BY-SA 4.0
2024-05-17T03:45:40.863Z
2024-05-17T03:45:40.863Z
taleodor
<p>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?</p>
<p>Currently I have 2 files:</p>
<p>For arm64 (osx)</p>
<pre class="lang-yaml prettyprint-override"><code>services:
  typesense:
    image: docker.io/typesense/typesense:0.25.2-arm64
    container_name: typesense
    restart: on-failure
    ports:
      - &quot;8108:8108&quot;
    volumes:
      - ./typesense-data:/data
    command: '--data-dir /data --api-key=xyz --enable-cors'
</code></pre>
<p>For non arm64</p>
<pre class="lang-yaml prettyprint-override"><code>services:
  typesense:
    image: docker.io/typesense/typesense:0.25.2
    container_name: typesense
    restart: on-failure
    ports:
      - &quot;8108:8108&quot;
    volumes:
      - ./typesense-data:/data
    command: '--data-dir /data --api-key=xyz --enable-cors'
</code></pre>
<p>The only difference here is the <code>image</code>, and ideally running them e.g. <code>docker compose up -d</code> then let the engine decide which arch is appropriate in the host's machine instead of using <code>docker compose -f &lt;FILE&gt; up -d</code>.</p>

<docker><docker-compose>
Docker Compose: dynamically change the image architecture based on running host machine
Jaeyson
# Docker Compose: dynamically change the image architecture based on running host machine

(Asked by: username_0 on 2024-05-17)

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  up -d.

**Tags:** docker, docker-compose


---

## 1 answers

### Answer by username_1 on 2024-05-17. Score: 1 | Accepted answer

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).


---

