Setup: Windows 10 WSL

Working commands to open a shell on the NAS and then connect to docker instance

ssh admin@ -i ./qnap_001.pem
[~] # docker exec -it ubuntu /bin/bash

Now I would like to ssh in and connect to the docker instance but this does not work.

ssh admin@ -i ./qnap_001.pem "docker exec -it ubuntu /bin/bash"


sh: docker: command not found

I've spent a few hours reading posts but can't crack it. When solved I'll set it up with a hotkey in ConEmu to open the shell in the docker instance

  • 1
    Is the docker command in your $PATH? What happens if you run the full path /bin/docker /sbin/docker /usr/sbin... – user742864 May 12 at 20:24

You probably need to run ssh with -t to allocate a TTY for the remote session:

ssh -t admin@ -i ./qnap_001.pem "docker exec..."

Your immediate problem is probably that the directory containing docker isn't in your PATH on the remote system, because whatever adds that directory to your PATH didn't execute.

When you run invoke ssh and specify a command to run on the remote system, ssh doesn't allocate a TTY for the remote session by default. The remote shell may initialize itself differently because it doesn't have a TTY. In particular, it probably didn't execute whatever statement adds the docker directory to your PATH.

The ssh -t option directs ssh to allocate a TTY for the session. This should result in your shell initializing itself the same way it would for an interactive session.

| improve this answer | |
  • Thank you, that's the info I needed 😊 Final working command ssh -t admin@ -i ./qnap_001.pem "/share/CACHEDEV1_DATA/.qpkg/container-station/bin/docker exec -it ubuntu /bin/bash" – chris loughnane May 13 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.