From 1dd67f8deac1bdd38d0bb2d630773101a5f3345c Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Wed, 10 Jun 2026 15:57:48 -0400 Subject: [PATCH] integration-cli: get container id from stdout only TestDaemonRestartWithNames in the DockerDaemonSuite has been broken since commit 72ec7cd6cc193f9054d1a58b8de244bd99c1d841. The test takes the combined output of a `docker run` command as the ID of the created container. This works fine so long as the command emits no warnings, otherwise it will corrupt the ID that the test captures. Modify the test to read the ID from the command's stdout to make the test robust to warnings being printed. Signed-off-by: Cory Snider --- integration-cli/daemon/daemon.go | 8 +++++++- integration-cli/docker_cli_daemon_test.go | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/integration-cli/daemon/daemon.go b/integration-cli/daemon/daemon.go index 4919c7ebb0..1094fc21e4 100644 --- a/integration-cli/daemon/daemon.go +++ b/integration-cli/daemon/daemon.go @@ -37,10 +37,16 @@ func New(t testing.TB, dockerBinary string, dockerdBinary string, ops ...daemon. // Cmd executes a docker CLI command against this daemon. // Example: d.Cmd("version") will run docker -H unix://path/to/unix.sock version func (d *Daemon) Cmd(args ...string) (string, error) { - result := icmd.RunCmd(d.Command(args...)) + result := d.RunCmd(args...) return result.Combined(), result.Error } +// RunCmd executes a docker CLI command against this daemon and returns the result. +// Example: d.RunCmd("version") will run docker -H unix://path/to/unix.sock version +func (d *Daemon) RunCmd(args ...string) *icmd.Result { + return icmd.RunCmd(d.Command(args...)) +} + // Command creates a docker CLI command against this daemon, to be executed later. // Example: d.Command("version") creates a command to run "docker -H unix://path/to/unix.sock version" func (d *Daemon) Command(args ...string) icmd.Cmd { diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go index e8dd08260f..6098dfb24a 100644 --- a/integration-cli/docker_cli_daemon_test.go +++ b/integration-cli/docker_cli_daemon_test.go @@ -1238,9 +1238,10 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithNames(c *testing.T) { assert.NilError(c, err, out) test2ID := strings.TrimSpace(out) - out, err = s.d.Cmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top") - assert.NilError(c, err) - test3ID := strings.TrimSpace(out) + res := s.d.RunCmd("run", "-d", "--name=test3", "--link", "test2:abc", "busybox", "top") + assert.NilError(c, res.Error) + // Discard any warnings about legacy links, which are emitted on stderr. + test3ID := strings.TrimSpace(res.Stdout()) s.d.Restart(c)