From 3d26a4fd20171eaf9d6006d7bb7d2e636ce1d47c Mon Sep 17 00:00:00 2001 From: Dean Chen <862469039@qq.com> Date: Thu, 20 Aug 2026 12:04:59 +0500 Subject: [PATCH] docker-container: wait for buildkitd before Dial A new builder can be Running before buildkitd binds its socket. DriverHandle caches the first Client() error, so that race is sticky. Signed-off-by: Dean Chen <862469039@qq.com> --- driver/docker-container/driver.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/driver/docker-container/driver.go b/driver/docker-container/driver.go index a7688606995d..546a7fc01e5f 100644 --- a/driver/docker-container/driver.go +++ b/driver/docker-container/driver.go @@ -323,6 +323,12 @@ func (d *Driver) daemonPlatform(ctx context.Context) *ocispecs.Platform { return &p } +type nopSubLogger struct{} + +func (nopSubLogger) Wrap(_ string, fn func() error) error { return fn() } +func (nopSubLogger) Log(int, []byte) {} +func (nopSubLogger) SetStatus(*client.VertexStatus) {} + func (d *Driver) wait(ctx context.Context, l progress.SubLogger) error { try := 1 for { @@ -517,6 +523,12 @@ func (d *Driver) Dial(ctx context.Context) (net.Conn, error) { } func (d *Driver) Client(ctx context.Context, opts ...client.ClientOpt) (*client.Client, error) { + // Info() is Running as soon as the container process is up, which can be + // before buildkitd has bound its socket. Boot() skips Bootstrap() in that + // case and DriverHandle caches the first Client() error, so wait here too. + if err := d.wait(ctx, nopSubLogger{}); err != nil { + return nil, err + } conn, err := d.Dial(ctx) if err != nil { return nil, err