Open paulomorgado opened 5 days ago
What do you think should be default behaviour?
$ podman build --help | grep iid
--iidfile file file to write the image ID to
$ docker build --help | grep iid
--iidfile string Write the image ID to a file
If this is real docker not writing to the file, then it seems like a Docker bug?
docker is writing nothing to the file when using podman engine, but writes the image ID when using docker engine.
Looks like something in the API that podman exposes to docker.
Ok do docker->Podman.sock, ends up with nothing in the file, which means we are somehow not responding the way docker expects.
That's probably it.
I need to debug a bit more to figure out what exactly is missing or out of place.
I built this simple C# program:
using Docker.DotNet;
using Docker.DotNet.Models;
using System.Formats.Tar;
using var contents = new MemoryStream();
using (var tarWriter = new TarWriter(contents, TarEntryFormat.Pax, true))
{
using var dockerfile = new MemoryStream();
dockerfile.Write(
"""
FROM alpine:latest
RUN echo 'x' > x.txt
"""u8);
dockerfile.Seek(0, SeekOrigin.Begin);
var tarEntry = new PaxTarEntry(TarEntryType.RegularFile, "Dockerfile");
tarEntry.DataStream = dockerfile;
await tarWriter.WriteEntryAsync(tarEntry);
}
contents.Seek(0, SeekOrigin.Begin);
using var configuration = new DockerClientConfiguration();
var client = configuration.CreateClient();
var imageBuildParameters = new ImageBuildParameters
{
Dockerfile = "Dockerfile",
Tags = ["test"],
};
await client.Images.BuildImageFromDockerfileAsync(
imageBuildParameters,
contents,
[],
new Dictionary<string, string>(),
new Progress<JSONMessage>(value =>
{
if (!string.IsNullOrEmpty(value.Stream))
{
Console.WriteLine($"Stream: {value.Stream}");
}
if (!string.IsNullOrEmpty(value.Status))
{
Console.WriteLine($"Status: {value.Status}");
}
if (value.Error is { } error)
{
Console.WriteLine($"Error {error.Code}: {error.Message}");
throw new Exception(error.Message);
}
if (!string.IsNullOrEmpty(value.ProgressMessage))
{
Console.WriteLine($"Progress: {value.ProgressMessage}");
}
if (!string.IsNullOrEmpty(value.ID))
{
Console.WriteLine($"ID: {value.ID}");
}
}));
And got this output from Rancher Desktop engine:
Stream: Step 1/2 : FROM alpine:latest
Stream:
Stream: ---> 63b790fccc90
Stream: Step 2/2 : RUN echo 'x' > x.txt
Stream:
Stream: ---> Using cache
Stream: ---> 6b7927809dfe
Stream: Successfully built 6b7927809dfe
Stream: Successfully tagged test:latest
And this from Podman engine:
Stream: STEP 1/2: FROM alpine:latest
Stream: STEP 2/2: RUN echo 'x' > x.txt
Stream: --> Using cache 0e707b89078f1e6c085941ad61de66d5439299bae750e028fe3ee48bf22eaa1b
Stream: COMMIT docker.io/library/test:latest
Stream: --> 0e707b89078f
Stream: Successfully tagged docker.io/library/test:latest
Stream: 0e707b89078f1e6c085941ad61de66d5439299bae750e028fe3ee48bf22eaa1b
Stream: Successfully built 0e707b89078f
Stream: Successfully tagged test
So, not much difference here.
But using this docker CLI:
Client:
Version: 27.3.1
API version: 1.41 (downgraded from 1.47)
Go version: go1.22.7
Git commit: ce12230
Built: Fri Sep 20 11:42:27 2024
OS/Arch: windows/amd64
Context: default
Server: linux/amd64/fedora-40
Podman Engine:
Version: 5.2.3
APIVersion: 5.2.3
Arch: amd64
BuildTime: 2024-09-24T01:00:00+01:00
Experimental: false
GitCommit:
GoVersion: go1.22.7
KernelVersion: 5.15.167.4-microsoft-standard-WSL2
MinAPIVersion: 4.0.0
Os: linux
Conmon:
Version: conmon version 2.1.12, commit:
Package: conmon-2.1.12-2.fc40.x86_64
OCI Runtime (crun):
Version: crun version 1.17
commit: 000fa0d4eeed8938301f3bcf8206405315bc1017
rundir: /run/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
Package: crun-1.17-1.fc40.x86_64
Engine:
Version: 5.2.3
API version: 1.41 (minimum version 1.24)
Go version: go1.22.7
Git commit:
Built: Tue Sep 24 01:00:00 2024
OS/Arch: linux/amd64
Experimental: false
the iid file ends up empty. The file is created with 0 bytes.
I think we need to examine the difference between the API when talking to the docker daemon versus talking to the podman service.
I've looked a bit more into it, and it looks like an issue with https://github.com/docker/buildx.
I've opened https://github.com/docker/buildx/issues/2820
Issue Description
docker build --iidfile <path to iidfile> ...
produces an empty file whilepodman build --iidfile <path to iidfile> ...
produces a file with the image ID.Steps to reproduce the issue
Steps to reproduce the issue
docker build --iidfile iid.txt -f Dockerfile .
iid.txt
file is emptypodman build --iidfile iid.txt -f Dockerfile .
iid.txt
file has the image IDDescribe the results you received
No image ID written to the iidfile when using docker CLI.
Describe the results you expected
Image ID written to the iidfile when using docker CLI.
podman info output
Podman in a container
No
Privileged Or Rootless
None
Upstream Latest Release
Yes
Additional environment details
Windows 11
Additional information
No response