
jaeyson
Docker Compose: dynamically change the image architecture based on running host machine
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?
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
.
Marked As Solved

conradwt
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:
services:
typesense:
image: 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'
Now, the above should run the appropriate Docker image platform variant for the host architecture.
Also Liked

jkdiaz
I doubt that you can do this dynamically. Or maybe I am wrong. But using separate files might be the simplest way.

faust
I haven’t tried it myself but I guess you can use environment variables
image: docker.io/typesense/${MY_VARIABLE}"
Then in your shell you declare a variable called MY_VARIABLE according to your system
You can read more here:
Popular Cross Platform topics

Other popular topics










Latest in Questions
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /julia
- /slackware
- /c
- /neovim