From 377773ab5b855fdaa32fba0896768aa97674c7e6 Mon Sep 17 00:00:00 2001 From: Boaz Shuster Date: Fri, 16 Sep 2022 10:52:58 +0300 Subject: Fix podman-remote run --attach stdin to show container ID Signed-off-by: Boaz Shuster --- pkg/domain/infra/tunnel/containers.go | 3 +++ test/system/030-run.bats | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go index 572807ad6..4f955e45c 100644 --- a/pkg/domain/infra/tunnel/containers.go +++ b/pkg/domain/infra/tunnel/containers.go @@ -620,6 +620,9 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID s } func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input, output, errput *os.File) error { + if output == nil && errput == nil { + fmt.Printf("%s\n", name) + } attachErr := make(chan error) attachReady := make(chan bool) options := new(containers.AttachOptions).WithStream(true) diff --git a/test/system/030-run.bats b/test/system/030-run.bats index b1ce91d14..8cd29e744 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -892,4 +892,14 @@ $IMAGE--c_ok" \ run_podman container rm -f -t 0 c_ok c_fail_no_rm } +@test "podman run --attach stdin prints container ID" { + ctr_name="container-$(random_string 5)" + run_podman run --name $ctr_name --attach stdin $IMAGE echo hello + run_output=$output + run_podman inspect --format "{{.Id}}" $ctr_name + ctr_id=$output + is "$run_output" "$ctr_id" "Did not find container ID in the output" + run_podman rm $ctr_name +} + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf