Shahar Hamuzim Rajuan
Shahar Hamuzim Rajuan

Reputation: 6139

Docker compose on cross-platform environment

Let's say I have a cross-platform environment,

my app is deployed twice - once on windows container and one on a Linux container,

In addition, I have a DB container (Linux).

Can I use docker compose to build those 3 services?

I think not - because the images I use are built for a certain os type.

Am I right? and maybe I am wrong and there is a workaround for this?

Upvotes: 16

Views: 43214

Answers (2)

for docker compose you can use "platforms:" inside the build option. It works as an array, like:

build:
  context: mydir
  dockerfile: Dockerfile
  platforms:
    - "linux/amd64/v2"
    - "linux/arm64"

Upvotes: 1

Devin Turner
Devin Turner

Reputation: 226

Compose files using version 2.4 support the platform options, which allows for specifying the platform of the service.

platform: osx
platform: windows/amd64
platform: linux/arm64/v8

https://github.com/docker/docker.github.io/blob/master/compose/compose-file/compose-file-v2.md#platform

It should be noted that the platform option is not supported on v3 compose files.

A more in-depth explanation can be found here: https://devblogs.microsoft.com/premier-developer/mixing-windows-and-linux-containers-with-docker-compose/

Upvotes: 21

Related Questions