A multi-platform Dockerfile builds image variants for different target architectures from one definition. Base the image on a multi-platform image and restrict commands to operations supported by every target. section 12.2
Use this pattern carefully:
- Avoid platform-specific commands such as chmod when they may not work on every architecture. section 12.2
- Remember that RUN failures appear during building, but invalid CMD commands can leave an image that fails only when run. section 12.2
- Use separate platform-specific Dockerfiles when shared commands cannot support both Linux and Windows. section 12.2
A misleading multi-platform build
A folder-list Dockerfile can build successfully from a multi-platform base while mixing Linux and Windows commands. Running the resulting image then fails on every architecture because CMD contains invalid commands. section 12.2
