diff --git a/cli/command/container/rm.go b/cli/command/container/rm.go index c38256a468b4..eaa23dec04bc 100644 --- a/cli/command/container/rm.go +++ b/cli/command/container/rm.go @@ -88,7 +88,6 @@ func runRm(ctx context.Context, dockerCLI command.Cli, opts *rmOptions) error { for _, name := range opts.containers { if err := <-errChan; err != nil { if opts.force && errdefs.IsNotFound(err) { - _, _ = fmt.Fprintln(dockerCLI.Err(), err) continue } errs = append(errs, err) diff --git a/cli/command/container/rm_test.go b/cli/command/container/rm_test.go index 86f6c4e0a2e9..52452f949553 100644 --- a/cli/command/container/rm_test.go +++ b/cli/command/container/rm_test.go @@ -15,9 +15,10 @@ import ( func TestRemoveForce(t *testing.T) { for _, tc := range []struct { - name string - args []string - expectedErr string + name string + args []string + expectedErr string + expectedStderr string }{ {name: "without force", args: []string{"nosuchcontainer", "mycontainer"}, expectedErr: "no such container"}, {name: "with force", args: []string{"--force", "nosuchcontainer", "mycontainer"}, expectedErr: ""}, @@ -52,6 +53,7 @@ func TestRemoveForce(t *testing.T) { } else { assert.NilError(t, err) } + assert.Equal(t, cli.ErrBuffer().String(), tc.expectedStderr) sort.Strings(removed) assert.DeepEqual(t, removed, []string{"mycontainer", "nosuchcontainer"}) })