3

When I try to right click -> attach shell on any of my docker boxes, a terminal windows opens and outputs the following:

 *  Executing task: docker exec -it <container_id> bash 

zsh:1: command not found: docker

 *  The terminal process "/bin/zsh '-c', 'docker exec -it <container_id> bash'" failed to launch (exit code: 127). 
 *  Terminal will be reused by tasks, press any key to close it. 

When I run docker exec -it <container_id> bash manually, it works. The "attach shell" dropdown option just doesn't work. Why?

I've tried changing my default terminal to bash with no luck. I'm on Mac Monterey 12.1 with the M1 chip. With some digging I found a thread that mentioned this could be an issue with Mac but that thread was using a different OS version.

rioV8
  • 24,506
  • 3
  • 32
  • 49
Paul Sender
  • 376
  • 2
  • 19

1 Answers1

6

The problem was related to the following answer on a different question: https://stackoverflow.com/a/65304142/9731043

"your npm scripts in vscode is started with /bin/zsh -c (non-login non-interactive) This means scripts inside ~/.zshrc is not executed (and for the same reason ~/.zprofile). However, even in non-login non-interactive mode, ~/.zshenv is loaded."

In my case it was my path variables.

To fix I followed

Open ~/.zshrc and move whatever scripts that is loading yarn into ~/.zshenv

Copy the path variable that contains docker into ~/.zshenv.

~/.zshenv

export PATH="/usr/local/bin:$PATH"
Paul Sender
  • 376
  • 2
  • 19