compose icon indicating copy to clipboard operation
compose copied to clipboard

docker compose exec panic when running without -T option

Open shouze opened this issue 3 years ago • 11 comments

Description

Weird/BC break behavior of docker compose exec compared to previous/python implementation.

Steps to reproduce the issue:

  1. docker compose exec aService aCommandThatTryToWriteOnTTY

Describe the results you received:

PANIC! In cas I try to docker compose exec -T aService aCommandThatTryToWriteOnTTY then seems like the command doesn't execute at all, no output.

panic: provided file is not a console

goroutine 1 [running]:
github.com/containerd/console.Current(0xc00027cf50, 0x0)
	github.com/containerd/[email protected]/console.go:77 +0xd8
github.com/docker/compose-cli/cli/cmd/compose.runExec(0x14d6ec0, 0xc000304040, 0x14ec4f8, 0xc00055e620, 0xc00004ffe0, 0x7ffc4c1000fe, 0x3, 0xc000165ea0, 0x2, 0x2, ...)
	github.com/docker/compose-cli/cli/cmd/compose/exec.go:100 +0x3eb
github.com/docker/compose-cli/cli/cmd/compose.execCommand.func2(0x14d6ec0, 0xc000304040, 0xc000165e90, 0x3, 0x3, 0xc000046168, 0x12)
	github.com/docker/compose-cli/cli/cmd/compose/exec.go:62 +0xd8
github.com/docker/compose-cli/cli/cmd/compose.Adapt.func1(0xc0003ca500, 0xc000165e90, 0x3, 0x3, 0x0, 0x0)
	github.com/docker/compose-cli/cli/cmd/compose/compose.go:60 +0x12f
github.com/spf13/cobra.(*Command).execute(0xc0003ca500, 0xc00013a1b0, 0x3, 0x3, 0xc0003ca500, 0xc00013a1b0)
	github.com/spf13/[email protected]/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc0004ae780, 0xc0004ae780, 0xc00013a190, 0x5)
	github.com/spf13/[email protected]/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	github.com/spf13/[email protected]/command.go:897
github.com/docker/cli/cli-plugins/plugin.RunPlugin(0xc00057b450, 0xc0003a5400, 0x132a2bb, 0x5, 0x1331482, 0xb, 0x1499b19, 0xc, 0x0, 0x0, ...)
	github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:51 +0x146
github.com/docker/cli/cli-plugins/plugin.Run(0x13a0ab0, 0x132a2bb, 0x5, 0x1331482, 0xb, 0x1499b19, 0xc, 0x0, 0x0, 0x0, ...)
	github.com/docker/[email protected]+incompatible/cli-plugins/plugin/plugin.go:64 +0x13f
main.main()
	github.com/docker/compose-cli/main.go:37 +0x125

Describe the results you expected:

  1. A more proper error message if running without -T option
  2. That it can output the result of the executed command

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client: Docker Engine - Community
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:40 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:54:48 2021
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of docker context show:
You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.

Usage:  docker context COMMAND

Manage contexts

Commands:
  create      Create a context
  export      Export a context to a tar or kubeconfig file
  import      Import a context from a tar or zip file
  inspect     Display detailed information on one or more contexts
  ls          List contexts
  rm          Remove one or more contexts
  update      Update a context
  use         Set the current docker context

Run 'docker context COMMAND --help' for more information on a command.

Output of docker info:

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  app: Docker App (Docker Inc., v0.9.1-beta3)
  buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
  compose: Docker Compose (Docker Inc., 2.0.0-beta.3)
  ecs: Docker ECS (Docker Inc., v1.0.0-beta.2)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 22
  Running: 19
  Paused: 0
  Stopped: 3
 Images: 39
 Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc version: b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.11.10-051110-lowlatency
 Operating System: Ubuntu 20.04.2 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.33GiB
 Name: sebastien-XPS-13-7390
 ID: 37TE:LU4V:LOI4:H7EK:JPDS:EVFK:JGRV:SADT:G3Y4:V7U2:7WZZ:QKBB
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: shouze
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: true
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Additional environment details (AWS ECS, Azure ACI, local, etc.):

local

shouze avatar Jun 07 '21 09:06 shouze

panic is triggered from https://github.com/docker/compose-cli/blob/v2.0.0-beta.3/cli/cmd/compose/exec.go#L100 which is guarded by execOpts.Tty = !opts.tty, so running with -T you should not run this code.

@lorenrh isn't this the same issue you already investigated as a test failure on Docker Desktop?

ndeloof avatar Jun 08 '21 06:06 ndeloof

Yes, indeed its seems the same issue.

lorenrh avatar Jun 09 '21 12:06 lorenrh

Has anyone found a way to resolve this? We recently started getting this error on our GitHub Actions runner without any changes to our code/actions.

kieraneglin avatar Jan 24 '22 20:01 kieraneglin

My issue is closely related to this issue. As with here, I resolved it by adding the -T option

kieraneglin avatar Jan 24 '22 20:01 kieraneglin

hi there, having frequently failing step in GHAs since yesterday and getting similar issue to the above about panic: provided file is not a console and the step ends with Error: Process completed with exit code 2. I have tried several fixes but none worked, added -T flag after docker compose exec and also tried the no-tty flag after them but kept getting the same issue anyone advice what more I can try?

mohammedalnuaimi avatar Jan 25 '22 17:01 mohammedalnuaimi

What do your commands look like now?

For me, command that used to work was docker compose exec rails bundle install. This worked until yesterday (or at least that's when I noticed it) but now it returns panic: provided file is not a console. When I updated the command to docker compose exec -T rails bundle install, it started working again.

If that doesn't work for you, check the related issue I posed in my last comment. There were a few suggestions for specifying shell in your GitHub Actions file that also worked for me.

kieraneglin avatar Jan 25 '22 19:01 kieraneglin

thanks @kieraneglin for your reply, actually -T has sorted out our issue, the problem I was not referencing the branch am working on when I did this change initially, all good now, but not sure why this suddenly has started happening!

mohammedalnuaimi avatar Jan 26 '22 16:01 mohammedalnuaimi

While I believe that it's good that the error message is pointing the error in the right direction, having a go stacktrace may not help users understand that the problem is caused by them. Go panics don't seem appropriate for users.

Would it be possible to handle this error gracefully and give a simple, clean error message with steps to fix the issue?

gabrieldemarmiesse avatar Mar 21 '22 11:03 gabrieldemarmiesse

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 21 '22 09:09 stale[bot]

This appears to still be an issue as of today, but it's unclear to me whether it's on GitHub's or Docker's end

kieraneglin avatar Sep 21 '22 16:09 kieraneglin

This issue has been automatically marked as not stale anymore due to the recent activity.

stale[bot] avatar Sep 21 '22 16:09 stale[bot]

Code has significantly changed since 2021 on exec command, so closing this issue. Please create a new issue with detailed usage if you encounter a comparable gub

ndeloof avatar Dec 07 '22 16:12 ndeloof