@@ -25,10 +25,109 @@ $ docker buildx build --output type=tar[,parameters] .
2525
2626The following table describes the available parameters:
2727
28- | Parameter | Type | Default | Description |
29- | ------------------| ---------| ---------| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
30- | ` dest ` | String | | Path to copy files to |
31- | ` platform-split ` | Boolean | ` true ` | When using the local exporter with a multi-platform build, by default, a subfolder matching each target platform is created in the destination directory. Set it to ` false ` to merge files from all platforms into the same directory. |
28+ | Parameter | Type | Default | Description |
29+ | ---------------- | ------- | ------- | --------------------------------------------------------------------------------- |
30+ | ` dest ` | String | | Path to copy files to |
31+ | ` platform-split ` | Boolean | ` true ` | ` local ` exporter only. Split multi-platform outputs into platform subdirectories. |
32+
33+ ## Multi-platform builds with local exporter
34+
35+ The ` platform-split ` parameter controls how multi-platform build outputs are
36+ organized.
37+
38+ Consider this Dockerfile that creates platform-specific files:
39+
40+ ``` dockerfile
41+ FROM busybox AS build
42+ ARG TARGETOS
43+ ARG TARGETARCH
44+ RUN mkdir /out && echo foo > /out/hello-$TARGETOS-$TARGETARCH
45+
46+ FROM scratch
47+ COPY --from=build /out /
48+ ```
49+
50+ ### Split by platform (default)
51+
52+ By default, the local exporter creates a separate subdirectory for each
53+ platform:
54+
55+ ``` console
56+ $ docker buildx build \
57+ --platform linux/amd64,linux/arm64 \
58+ --output type=local,dest=./output \
59+ .
60+ ```
61+
62+ This produces the following directory structure:
63+
64+ ``` text
65+ output/
66+ ├── linux_amd64/
67+ │ └── hello-linux-amd64
68+ └── linux_arm64/
69+ └── hello-linux-arm64
70+ ```
71+
72+ ### Merge all platforms
73+
74+ To merge files from all platforms into the same directory, set
75+ ` platform-split=false ` :
76+
77+ ``` console
78+ $ docker buildx build \
79+ --platform linux/amd64,linux/arm64 \
80+ --output type=local,dest=./output,platform-split=false \
81+ .
82+ ```
83+
84+ This produces a flat directory structure:
85+
86+ ``` text
87+ output/
88+ ├── hello-linux-amd64
89+ └── hello-linux-arm64
90+ ```
91+
92+ Files from all platforms merge into a single directory. If multiple platforms
93+ produce files with identical names, the export fails with an error.
94+
95+ ### Single-platform builds
96+
97+ Single-platform builds export directly to the destination directory without
98+ creating a platform subdirectory:
99+
100+ ``` console
101+ $ docker buildx build \
102+ --platform linux/amd64 \
103+ --output type=local,dest=./output \
104+ .
105+ ```
106+
107+ This produces:
108+
109+ ``` text
110+ output/
111+ └── hello-linux-amd64
112+ ```
113+
114+ To include the platform subdirectory even for single-platform builds, explicitly
115+ set ` platform-split=true ` :
116+
117+ ``` console
118+ $ docker buildx build \
119+ --platform linux/amd64 \
120+ --output type=local,dest=./output,platform-split=true \
121+ .
122+ ```
123+
124+ This produces:
125+
126+ ``` text
127+ output/
128+ └── linux_amd64/
129+ └── hello-linux-amd64
130+ ```
32131
33132## Further reading
34133
0 commit comments