Maybe I am misunderstanding here but --output=type=image
is not outputting my just built images to images since a docker images
fails to list the just built ones.
Here’s an example.
Add to a directory hello_world.c
and Dockerfile
as follows:
hello_world.c
#include <stdio.h>
int main(void) {
printf("hello world\n");
}
Dockerfile
FROM debian:stable
RUN apt update && \
apt install -y gcc
ADD ./hello_world.c .
RUN gcc -o hello_world hello_world.c
CMD ['./hello_world']
Assuming you have buildx
plugin setup and experimental
flag enabled, run:
$ buildx-example docker buildx create --name mybuilder
mybuilder
$ buildx-example docker buildx use mybuilder
$ docker buildx build --platform linux/amd64,linux/386,linux/arm/v7 --output=type=image,name=helloworld .
[+] Building 1.8s (19/19) FINISHED
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 149B 0.0s
=> [linux/arm/v7 internal] load metadata for docker.io/library/debian:stable 1.3s
=> [linux/amd64 internal] load metadata for docker.io/library/debian:stable 1.4s
=> [linux/386 internal] load metadata for docker.io/library/debian:stable 1.3s
=> [linux/386 1/4] FROM docker.io/library/debian:stable@sha256:4d1374a1b646c1d90e298778226dc7013dcabbc66cc9f 0.0s
=> => resolve docker.io/library/debian:stable@sha256:4d1374a1b646c1d90e298778226dc7013dcabbc66cc9f0973b3e2e5 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 151B 0.0s
=> [linux/arm/v7 1/4] FROM docker.io/library/debian:stable@sha256:4d1374a1b646c1d90e298778226dc7013dcabbc66c 0.0s
=> => resolve docker.io/library/debian:stable@sha256:4d1374a1b646c1d90e298778226dc7013dcabbc66cc9f0973b3e2e5 0.0s
=> CACHED [linux/386 2/4] RUN apt update && apt install -y gcc 0.0s
=> CACHED [linux/386 3/4] ADD ./hello_world.c . 0.0s
=> CACHED [linux/386 4/4] RUN gcc -o hello_world hello_world.c 0.0s
=> CACHED [linux/arm/v7 2/4] RUN apt update && apt install -y gcc 0.0s
=> CACHED [linux/arm/v7 3/4] ADD ./hello_world.c . 0.0s
=> CACHED [linux/arm/v7 4/4] RUN gcc -o hello_world hello_world.c 0.0s
=> [linux/amd64 1/4] FROM docker.io/library/debian:stable@sha256:4d1374a1b646c1d90e298778226dc7013dcabbc66cc 0.0s
=> => resolve docker.io/library/debian:stable@sha256:4d1374a1b646c1d90e298778226dc7013dcabbc66cc9f0973b3e2e5 0.0s
=> CACHED [linux/amd64 2/4] RUN apt update && apt install -y gcc 0.0s
=> CACHED [linux/amd64 3/4] ADD ./hello_world.c . 0.0s
=> CACHED [linux/amd64 4/4] RUN gcc -o hello_world hello_world.c 0.0s
=> exporting to image 0.3s
=> => exporting layers 0.1s
=> => exporting manifest sha256:1024473951975973dc842c72354745d7b7fd28bbd4ba2bbb311ff61c1e61adbe 0.0s
=> => exporting config sha256:97806f928bd83d80e20ecaa8aa47bf4262227951700681e256c37a7281785ccf 0.0s
=> => exporting manifest sha256:580628ee58bf36ab7a384f7b65e1eca928627bec67cd2590391f530f3f392ee1 0.0s
=> => exporting config sha256:b61b63a6935e740c3ad8b0e9ab4bd30f21a97f78a265ac0dd4a58382c0f02c3f 0.0s
=> => exporting manifest sha256:85b48ab3c424d95d80aa21591813f7e3f4b758ff7eea3df189cb8c2c5f8d044f 0.0s
=> => exporting config sha256:847764e91840f3c337cba8ae19141dae9849e8fe47a214c4a578c489d3deda5d 0.0s
=> => exporting manifest list sha256:f5de24b3cef9ba9843695b855da291864ac50628616e0518c41d12ceecc40616 0.0s
If you now check your docker images, nothing called helloworld
is there. What’s going on? How can I run these images without push
ing them anywhere?