Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell hangs from CLI, works from Visual Studio (OS X) #556

Closed
justinlittman opened this issue Jun 19, 2023 · 14 comments · Fixed by #603
Closed

Shell hangs from CLI, works from Visual Studio (OS X) #556

justinlittman opened this issue Jun 19, 2023 · 14 comments · Fixed by #603
Assignees
Labels
bug Something isn't working
Milestone

Comments

@justinlittman
Copy link

OS X version: Darwin 22.5.0 (Ventura)
Docker version: Docker version 24.0.2, build cb74dfc
Docker compose version: Docker Compose version v2.18.1
VS Code version: 1.79.2 (Universal)
Devcontainer version: 0.42.0

devcontainer.json:

{
	"dockerComposeFile": "docker-compose.yml",
	"service": "devcontainer",
}

docker-compose.yml:

version: '3.6'

services:
  devcontainer:
    image: mcr.microsoft.com/devcontainers/ruby:3.1
    volumes:
      - ../..:/workspaces
    command: sleep infinity
  db:
    image: postgres:12
    environment:
      POSTGRES_DB: rv-metasearch
      POSTGRES_PASSWORD: postgres
    ports:
      - 5432:5432
    volumes:
      - postgres-data:/var/lib/postgresql/data
  redis:
    image: redis
    ports:
      - 6379:6379
    volumes:
      - redis-data:/data
volumes:
  postgres-data:
  redis-data:

Steps to reproduce (terminal):

  1. devcontainer up
  2. devcontainer exec bash (or any other shell).
  3. ls
    The terminal then hangs.

Steps to reproduce (VS Code):

  1. devcontainer up
  2. Devcontainers: Attach to a running container ...
  3. Select the devcontainer container.
  4. View > Terminal
  5. ls
    The command executes as expected.

My apologies in advance if I am misunderstanding something about how the CLI is intended to work.

@bamurtaugh
Copy link
Member

Hi @justinlittman, thanks for opening!

I was able to use the following in the command line, working on a GitHub\helloexpress project

  • cd GitHub
  • devcontainer up --workspace-folder helloexpress
    • The output of this command prints a container id, which I used in the next command
  • devcontainer exec --container-id <container_id_from_above> ls

Please let me know if this makes sense and works any better for you.

@justinlittman
Copy link
Author

devcontainer exec ls works as expected. However, I'm trying to get an interactive shell running in the container (bash or any other shell).

@bamurtaugh
Copy link
Member

Ah thanks for clarifying!

That was implemented through #59. Does devcontainer exec bash work well for you? That appears to work for me.

@justinlittman
Copy link
Author

devcontainer exec bash hangs for me. Are you on OS X @bamurtaugh?

@bamurtaugh
Copy link
Member

Ah got it, @chrmarti @alexander-smolyakov could you try to repro?

@chrmarti chrmarti self-assigned this Jun 29, 2023
@chrmarti
Copy link
Contributor

Works for me on Mac:

❯ devcontainer exec --workspace-folder . bash
vscode ➜ / $ ls
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  workspaces
vscode ➜ / $ 

Could you post the output you get for comparison?

@chrmarti chrmarti added the info-needed Issue requires more information from poster label Jun 29, 2023
@justinlittman
Copy link
Author

devcontainer exec --workspace-folder . bash
vscode ➜ / $ ls

and then it hangs.

@chrmarti
Copy link
Contributor

Does devcontainer exec --workspace-folder . bash -lic ls work?

@justinlittman
Copy link
Author

Works:

devcontainer exec --workspace-folder . bash -lic ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  workspaces

Hangs:

devcontainer exec --workspace-folder . bash -li
vscode ➜ / $ ls

@magnomp
Copy link

magnomp commented Jul 4, 2023

Same here, but its not that it hangs. It actually let you type indefinitely but doesnt respond do anything:

magno@magno-note:~/Documentos/devcontainer-test$ devcontainer exec --workspace-folder . bash
node ➜ /workspaces/devcontainer-test (master) $ ls
ls
sdfsdf
sdfsfdf

Doing some tests, it seems to be the same as invoking docker exec without the -i argument:

magno@magno-note:~/Documentos/devcontainer-test$ docker exec -it 8e3 bash
root ➜ / $ ls
bin  boot  dev	etc  home  lib	lib64  media  mnt  opt	proc  root  run  sbin  srv  sys  tmp  usr  var	vscode	workspaces
root ➜ / $

(works)

magno@magno-note:~/Documentos/devcontainer-test$ docker exec -t 8e3 bash
root ➜ / $ ls
ls
sdfsdf

(hangs)

@LangdalP
Copy link

LangdalP commented Jul 6, 2023

Can confirm that I am experiencing the same on MacOS.

@dbader
Copy link

dbader commented Jul 18, 2023

Same issue for me on macOS, devcontainer exec bash hangs

$ devcontainer --version
0.46.0

@jetaggart
Copy link

jetaggart commented Jul 24, 2023

I'm experiencing this as well. It seems like any interactive command hangs, I can't even get a prompt and have to kill my whole shell to stop the process (won't even respond to ctrl-c).

devcontainer exec --workspace-folder . sh -> hangs terminal
devcontainer exec --workspace-folder . bash -li -> hangs terminal
devcontainer exec --workspace-folder . bash -lic ls -> works as expected

$ devcontainer --version
0.50.0

macOS 13.14.1, zsh on host, bash on container

@Drowze
Copy link

Drowze commented Jul 25, 2023

Using MacOS 13.2.1, running docker cli with colima. Also going through same behaviour as @jetaggart (note: killing the container with docker kill <sha> also cancel the process and get shell responsive again)

OS: MacOS 13.2.1
Docker version: 24.0.4, build 3713ee1eea
Docker Compose version: Docker Compose version 2.20.0
Colima version: colima version 0.5.5

(also not sure if relevant: but I'm running fish on the host machine and bash on the container, with Alacritty terminal emulator)

@chrmarti chrmarti added bug Something isn't working and removed info-needed Issue requires more information from poster labels Jul 26, 2023
@chrmarti chrmarti added this to the July 2023 milestone Jul 26, 2023
@chrmarti chrmarti mentioned this issue Jul 26, 2023
chrmarti added a commit that referenced this issue Jul 26, 2023
chrmarti added a commit that referenced this issue Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants