dockerdocker-composedocker-image

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?


Solution

  • 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/