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

Support remote docker over ssh #3831

Merged
merged 3 commits into from Oct 7, 2022

Conversation

dgageot
Copy link
Contributor

@dgageot dgageot commented Oct 3, 2022

I've got a remote docker daemon that I connect to over ssh.
Something like DOCKER_HOST=ssh://docker-remote docker ps works well

When I use linuxkit, with DOCKER_HOST set to ssh://docker-remote it'll silently fail to connect.

This introduced the support for a remote docker over ssh.

Signed-off-by: David Gageot david.gageot@docker.com

Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
Signed-off-by: David Gageot <david.gageot@docker.com>
@dgageot dgageot changed the title Don't use deprecated api Support remote docker over ssh Oct 3, 2022
Copy link
Contributor

@djs55 djs55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I tested by setting DOCKER_HOST=ssh://username@windows.host on my Mac (to be adventurous) and then linuxkit build -format iso-efi examples/getty.yml. Initially I wasn't sure what was happening but then I deliberately misconfigured my Windows Docker Desktop HTTP proxy and verified that the error was reported on my Mac.

@dgageot
Copy link
Contributor Author

dgageot commented Oct 7, 2022

Hi @deitch, do you think this one can be merged too? It pretty important when using a remote docker to be able to connect over ssh.

@deitch
Copy link
Collaborator

deitch commented Oct 7, 2022

I am not sure I get the use case. Is this for building packages lkt pkg build? Linuxkit already has a set of rules for using docker contexts for that. Or is it for getting to the docker daemon where the contexts are provided? Or something else entirely?

@dgageot
Copy link
Contributor Author

dgageot commented Oct 7, 2022

@deitch When one sets DOCKER_HOST or creates a docker context, linuxkit will indeed pick it up correctly. However, if the docker daemon that this points to is reached over ssh, linuxkit will fail to actually talk to the daemon.
Connecting over ssh is something not too old and the standard docker library doesn't do that auto magically.

@deitch
Copy link
Collaborator

deitch commented Oct 7, 2022

I still don't fully get it.

  • is this for lkt pkg build? Or some other scenario.
  • when running lkt pkg build, it just uses docker contexts based on the docker daemon to which it communicates. Is this to set which docker daemon that is?

@dgageot
Copy link
Contributor Author

dgageot commented Oct 7, 2022

It's for lkt pkg build and lkt build. Anytime linuxkit tries to connect to Docker.
Let me try to rephrase what this PR is doing:

It adds the support to ssh: scheme to connect to a remote Docker.

Let's say I run those commands to create a dedicated context:

$ docker context create mybuilder --docker host=ssh://docker-remote
$ docker context use mybuilder
$ linuxkit build -docker linuxkit.yml
Extract kernel image: docker.io/linuxkit/kernel:5.10.104
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Because linuxkit doesn't support ssh:* as a daemon url, it'll just connect locally, totally ignoring the docker context. And it'll do that silently because in the code, we swallow all the errors for the (good) reason that we should be able to build without docker. (The "Cannot connect" error I pasted, is not shown, I had to change the linuxkit code to show it)

@deitch
Copy link
Collaborator

deitch commented Oct 7, 2022

OK got it.

@deitch deitch merged commit 07adfa2 into linuxkit:master Oct 7, 2022
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

Successfully merging this pull request may close these issues.

None yet

3 participants