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
[FEATURE] add import-image command for importing single image #83
Conversation
Update: the changes in this branch leverage goroutines to run the
|
Here are some high level comments from q quick glance. I have not reviewed the code line by line.
k3d load -n test1 image1 imag2 ... imageN
|
Let's add
I already dropped the
You're right, I'll have a look into that 👍 |
One problem I found while working on a solution using docker volume is, that with default settings, we may not have access to the volume directory that docker uses, so we'll have to figure out a way to either UPDATE: An idea could be to spawn a container than has the Docker CLI in it (or a script using the API) that shares the docker socket (or has access to the API) and mounts the named volume. This could then directly run a My brain is hurting a bit from thinking about this for too long... maybe I'm missing something obvious here? @andyz-dev |
Your call. In general, I am not a big fan of alias. But it probably make sense in this case, as you have pointed out.
|
Actually, you just need to start a container (without running) mounting the volume, then docker API can directly access to the volume. We can just reuse the k3s image as the dummy container for mounting the volume so we don't have pull another docker image unnecessarily. A nice touch would be to have the dummy container mount the volume as read-write, for doing 'docker cp'. while the volume should be attached to the k3s nodes as read-only. |
I think we're talking about the same thing in the end, but what do you mean with
Definitely a good idea I'd say 👍 |
The following example may be helpful to illustrate what I mean:
|
I understand what you want to do, but since That means, that first you have to get the tarball to your local machine. As the goal of this PR is to export an image that you've built before using docker (which might be on the remote machine), you have to run Thus, you'd copy the tarball twice: from the docker host to your localhost ( If you already have the tarball locally due to some reason, then the proposed That's why I thought, we could completely skip the transfer of the tarball from the docker host to localhost and back by simply spawning a I don't think that this is a super clean way of doing it, but it has two big benefits:
The drawbacks that I see:
WDYT? |
I agree with your analysis. k3d-helper approach would be more efficient in saving networking bandwidth than using the dummy container. Here is my take on the design: I believe the majority of users will not be using remote docker since k3d is mainly aimed at laptop development. Not having to maintain another image makes k3d easier to use. I view k3d-helper as an optional solution that can be developed later when we hear more about the bandwidth concern. On the other hand, I do not oppose if we make k3d-helper as the primary solution. |
I agree with your belief that it's mostly being used with a local docker daemon (tbh, I most often didn't consider the other case, e.g. when I first created this PR). For the short term solution, I will go with the solution that you proposed (dummy container + Thanks for the healthy discussion and the honest feedback :) |
Closing this for now until we found a proper solution without too many drawbacks that works for the use with a local and a remote docker daemon. |
Can we use docker local as docker repo for k3d e,g: localhost:5000/some-repo:v23456 |
If you have a registry running then yes, but you have to edit the containerd config to be able to pull from there. There is another issue open regarding pulling from private registries and some discussions in slack (rancher-users, #k3d). Is that what you mean? |
This PR adds a stand-alone
k3d import-image
command that can be used like this:k3d import-image -n test0 -i nginx:local
This would do the following:
docker save
to save the image from the local docker daemon to a tar archive (in a directory that's bind-mounted into all the node containers)ctr image import
to make the image usable by containerd inside the containersRequirements:
<clusterDir>/images
) into all the node containersctr
in k3sctr
in k3s :)Up for improvement:
--image/-i
Note:
This is still in very early phase, so this PR is mainly made for contributors and testers to have a look and give an opinion :)
Issue Reference: #19