nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

"provided file is not a console" panic error when using nerdctl run -it

Open protoz opened this issue 3 years ago • 5 comments

Nerdctl version 0.12.1 (Latest Rancher Desktop)

When running the command below to create a template from a helm chart and apply it with kubectl I am getting a containerd panic

Command:

nerdctl run -it -v $PWD:/myApp alpine/helm:2.14.3 template \
  -f values.yaml \
  --set-string serviceAccountKeyFile="$myServiceAccountKey" \
  . | kubectl apply -f -

Current behavior:

panic: provided file is not a console

goroutine 1 [running]:
github.com/containerd/console.Current()
        /go/pkg/mod/github.com/containerd/[email protected]/console.go:77 +0xa5
main.runAction(0xc000364680)
        /go/src/github.com/containerd/nerdctl/cmd/nerdctl/run.go:636 +0x2c85
github.com/urfave/cli/v2.(*Command).Run(0x1895740, 0xc0002fea00)
        /go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:163 +0x64a
github.com/urfave/cli/v2.(*App).RunContext(0xc000083040, {0x115eed8, 0xc0000340b0}, {0xc0000300e0, 0xe, 0xe})
        /go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:313 +0x81e
github.com/urfave/cli/v2.(*App).Run(...)
        /go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:224
main.xmain()
        /go/src/github.com/containerd/nerdctl/cmd/nerdctl/main.go:55 +0xa5
main.main()
        /go/src/github.com/containerd/nerdctl/cmd/nerdctl/main.go:43 +0x19

Expected Behavior: nerdctl does not panic when using the -t flag

Workarounds found: If I run it without pseudo-terminal (-t) it seems to work just fine.

protoz avatar Nov 23 '21 20:11 protoz

I think it's the redirect of output, in this case to tee. I get the same panic when I try to send the output to a file with tee

claw-real avatar Jan 12 '22 10:01 claw-real

The similar thing:

❯ nerdctl exec -itu postgres back_postgres_1 psql < ../db-2022-01-28.sql
panic: provided file is not a console

goroutine 1 [running]:
github.com/containerd/console.Current()
	/go/pkg/mod/github.com/containerd/[email protected]/console.go:77 +0xd4
main.execActionWithContainer({0x1195660, 0x40003e6800}, 0x4000369180, {0x40000caf80, 0x2, 0x4}, {0x11b21d8, 0x400013a780}, 0x40001ae000)
	/go/src/github.com/containerd/nerdctl/cmd/nerdctl/exec.go:175 +0x674
main.execAction.func1({0x1195660, 0x40003e6800}, {{0x11b21d8, 0x400013a780}, {0xffffcce27e64, 0xf}, 0x0, 0x1})
	/go/src/github.com/containerd/nerdctl/cmd/nerdctl/exec.go:87 +0xe8
github.com/containerd/nerdctl/pkg/idutil/containerwalker.(*ContainerWalker).Walk(0x40004cfd20, {0x1195660, 0x40003e6800}, {0xffffcce27e64, 0xf})
	/go/src/github.com/containerd/nerdctl/pkg/idutil/containerwalker/containerwalker.go:68 +0x378
main.execAction(0x4000369180, {0x40000caf80, 0x2, 0x4})
	/go/src/github.com/containerd/nerdctl/cmd/nerdctl/exec.go:91 +0x2e0
github.com/spf13/cobra.(*Command).execute(0x4000369180, {0x400003a200, 0x4, 0x4})
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:856 +0x678
github.com/spf13/cobra.(*Command).ExecuteC(0x4000368a00)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x424
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:902
main.xmain()
	/go/src/github.com/containerd/nerdctl/cmd/nerdctl/main.go:84 +0xf8
main.main()
	/go/src/github.com/containerd/nerdctl/cmd/nerdctl/main.go:67 +0x20

yerzhant avatar Jan 31 '22 09:01 yerzhant

Perhaps better to report this to https://github.com/rancher-sandbox/rancher-desktop/issues .

Please make sure to include the host OS and the terminal application in the report.

AkihiroSuda avatar Feb 06 '22 10:02 AkihiroSuda

Reopening, this is not relevant to rancher desktop but relevant to pipes

AkihiroSuda avatar Aug 08 '22 14:08 AkihiroSuda

docker updated to show a help message:

 $ docker run -it --rm someimage
the input device is not a TTY.  If you are using mintty, try prefixing the command with 'winpty'

Which is the correct "fix" for the problem.

gcb avatar Oct 10 '22 17:10 gcb

Hi. I encountered similar problem when nerdctl execute on background. Is there any solutions?

I thought it would be fixed at https://github.com/containerd/nerdctl/pull/2167 and not occur in version 1.3.1 or later, but it did occur.

The steps to reproduce are as follows:

test.sh

#!/usr/bin/env bash

set -eu
set -o pipefail

./test-in-host.sh &

PID=$!

wait $PID

test-in-host.sh

#!/usr/bin/env bash

nerdctl run --rm -t -v "`pwd`:/tmp/" ubuntu bash /tmp/test-in-container.sh

test-in-container.sh

#!/usr/bin/env bash

echo "some output"

run some commands.

~/D/docker-nerdctl-test ❯❯❯ nerdctl version
Client:
 Version:       v1.4.0
 OS/Arch:       linux/amd64
 Git commit:    7e8114a82da342cdbec9a518c5c6a1cce58105e9
 buildctl:
  Version:      v0.11.6
  GitCommit:    2951a28cd7085eb18979b1f710678623d94ed578

Server:
 containerd:
  Version:      v1.7.0
  GitCommit:    1fbd70374134b891f97ce19c70b6e50c7b9f4e0d
 runc:
  Version:      1.1.7
  GitCommit:    860f061b76bb4fc671f0f9e900f7d80ff93d4eb7
~/D/docker-nerdctl-test ❯❯❯ ./test.sh
panic: provided file is not a console

goroutine 1 [running]:
github.com/containerd/console.Current()
        /go/pkg/mod/github.com/containerd/[email protected]/console.go:77 +0xa5
main.runAction(0xc000004900, {0xc0006d2070, 0x3, 0x7})
        /go/src/github.com/containerd/nerdctl/cmd/nerdctl/container_run.go:349 +0x6c5
github.com/spf13/cobra.(*Command).execute(0xc000004900, {0xc00003e0b0, 0x7, 0x7})
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:940 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0xc000004300)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).Execute(...)
        /go/pkg/mod/github.com/spf13/[email protected]/command.go:992
main.xmain()
        /go/src/github.com/containerd/nerdctl/cmd/nerdctl/main.go:136 +0x9f
main.main()
        /go/src/github.com/containerd/nerdctl/cmd/nerdctl/main.go:119 +0x19
Error: exit status 2

hiragi-gkuth avatar Sep 12 '23 06:09 hiragi-gkuth