1

Setup: Windows 10 WSL

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

ssh [email protected] -i ./qnap_001.pem
[~] # docker exec -it ubuntu /bin/bash
root@ubuntu:/#

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

ssh [email protected] -i ./qnap_001.pem "docker exec -it ubuntu /bin/bash"

Returns

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
  • 1
    Is the docker command in your $PATH? What happens if you run the full path /bin/docker /sbin/docker /usr/sbin...
    – user324747
    May 12, 2020 at 20:24

1 Answer 1

1

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

ssh -t [email protected] -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.

1
  • Thank you, that's the info I needed 😊 Final working command ssh -t [email protected] -i ./qnap_001.pem "/share/CACHEDEV1_DATA/.qpkg/container-station/bin/docker exec -it ubuntu /bin/bash" May 13, 2020 at 15:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .