Rootless Docker can not use context

Hi there!

I’ve installed Docker in rootless mode on my remote server following this guide:

So I ended with the docker binaries in ~/bin/
If I add this path to my .bashrc file, it’s ok, I can run docker while I’m connected to my server via ssh on a terminal.

My problem is when from my local computer, I execute docker commands using docker context.
I have a context already setup locally named remote and it is set to ssh://<user>@<host>, my local ssh config knows how to connect to the remote machine.

The thing is when you execute docker commands with context, the PATH to ~/bin not set is unknown so the docker binary is not found.

For example

docker --context remote ps

Gives me

error during connect: Get "": command [ssh -o ConnectTimeout=30 -- remote 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=bash: line 1: docker: command not found

What can I do about this?

Setting the PATH in .bashrc doesn’t help since is for the logged user on a terminal…
The following seems useless for docker context.

[INFO] Make sure the following environment variable(s) are set (or add them to ~/.bashrc):
export PATH=/home/ubuntu/bin:$PATH

Any idea? Thanks!

Maybe I missed something, but I don’t see the documentation mentioning the bin folder in the user HOME.You you could just install Docker normally and disable it so you can use the rootless context.
It doesn’t matter where the docker executable. It won’t be rootful just because the binary is not in your home. That is just the client. IF you don’t need the daemon, then just install the “docker-ce-cli” package not “docker-ce” (if rootless docker installs the daemon without it).

Thanks for your answer @rimelek
If you install docker without using packages, the binaries are in ~/bin/ like it is explained here on the docs :

So if I install docker with the package manager, the execute the rootless script, all I have to do is to set the context to rootless?

I see. I guess they didn’t think someone would use remote context with rootless Docker and the Documentation is not complete. I don’t know how it should work so as a workaround, I would tr to copy or just symlink the docker binary to the /usr/local/bin folder or install Docker globally too and disable it.