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

Docker ssh:// wont' work, stderr=zsh:1: command not found: docker #2115

Closed
ankanch opened this issue Sep 30, 2019 · 4 comments
Closed

Docker ssh:// wont' work, stderr=zsh:1: command not found: docker #2115

ankanch opened this issue Sep 30, 2019 · 4 comments

Comments

@ankanch
Copy link

ankanch commented Sep 30, 2019

I have the same problem, whereby I try to execute docker command from windows 10 to Docker on OS X 10.

as below:

kanch@LAPTOP-KANCH:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS           NAMES
kanch@LAPTOP-KANCH:~$ docker -H tcp://192.168.1.104:2375 ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS             NAMES
kanch@LAPTOP-KANCH:~$  docker -H ssh://platform@192.168.1.104 ps
error during connect: Get http://docker/v1.40/containers/json: command [ssh -l platform 192.168.1.104 -- docker system dial-stdio] has exited with exit status 127, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=zsh:1: command not found: docker

tcp:// just won't works as the reason is command docker not found.

I found in issues it is possible related to the shell I use, then I tried powershell, cmd, bash, git bash. NONE of them works.

is there any fix for this?

@AkihiroSuda
Copy link
Collaborator

On the remote host, PATH needs to be set.

@ankanch ankanch closed this as completed Oct 31, 2019
@JustDevZero
Copy link

JustDevZero commented Mar 22, 2021

Hmmm... I'm sorry for reopening, but this is somehow untrue, unless @ankanch had done anything that I missed:

echo PATH
/Users/zero/.virtualenvs/prueba/bin:/Users/zero/bin:/Users/zero/.toolbox/bin:/Users/zero/Library/Python/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin

In both, zsh and bash.

export DOCKER_HOST=ssh://zero@localhost

error during connect: Get http://docker/v1.24/containers/json: command [ssh -l zero -- localhost docker system dial-stdio] has exited with exit status 127, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=zsh:1: command not found: docker

which docker
/usr/local/bin/docker

uname -a
Darwin 147dda48aad1.ant.amazon.com 19.6.0 Darwin Kernel Version 19.6.0: Tue Jan 12 22:13:05 PST 2021; root:xnu-6153.141.16~1/RELEASE_X86_64 x86_64

docker --version
Docker version 20.10.0, build 7287ab3

In case of remote docker machines I have no problem, but trying to ssh against my self to make some tests/poc don't.

@Tylerc230
Copy link

I believe this is because PATH is not set when using ssh (not a login shell). This fails ssh <username>@<ip> 'docker info' but this works ssh <username>@<ip> '/usr/local/bin/docker info'

@zylyye
Copy link

zylyye commented Apr 9, 2022

I have encountered the same problem, that is because when we execute ssh command directly (ssh user@host command), the shell is started non-interactively and uses it's default PATH(you could see it by using ssh user@host env | grep PATH), so the fundamental question is how to set PATH of non-interactively shell:

  1. edit /etc/ssh/sshd_config and set PermitUserEnvironment yes
  2. edit ~/.ssh/environment and add PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
  3. restart your sshd server (on MacOS using sudo launchctl stop com.openssh.sshd; sudo launchctl start com.openssh.sshd)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants