-
-
Notifications
You must be signed in to change notification settings - Fork 452
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] import images from docker daemon into k3d #91
Conversation
…into feature/load-images
Found a small issue that may be worth fixing: Suppose local docker has the image alpine:3.9, the following command sequence can be improved with better error handling: bin/k3d import-images alpine:4.0 =2019/07/15 23:28:16 ERROR: couldn't save images [alpine:4.0] This error is expected, no problem. Then I won't be able import the right image any more. bin/k3d import-images alpine:3.9 Until the 'iwlltry42/k3d-tools:v0.0.1' container is manually deleted from docker. |
What's plan for maintaining the helper container? May be we should plan to build and release the helper containers for each k3d release? |
@andyz-dev true, I totally forgot about deleting the container again in case of error, because I moved the code back and forth quite a lot. I will fix this soon 👍 Right now, the helper container has a single functionality, so I'm unsure if it's worth building it everytime, though I don't have a problem with it, as that way we can ensure compatibility with each release 👍 |
I agree with you that a sub project may be an overkill. This is one of the downside of this approach. On the other hand, when we merge the PR in (hopefully soon), we will have to have a plan for publish the "official" image for it. Would it be possible to add a makefile rule (and a corresponding dockerfile) for building the image? The rule can be tied into the build-cross target, so that pushing an official image can be part of the release. If this is too much work, and keeping an separate repo is easier, that will be fine too. We can model it after how k3s images are supported. Personally, I'd prefer the makefile approach if it is possible. |
@andyz-dev ready for another review 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks for adding the fix.
Context
k3d import-images
to import docker images from the used docker daemon into containerd inside the k3d nodes.This is a new version of PR #83 which makes use of a named volume and an additional
k3d-tools
container.How it works
--image rancher/k3s:v0.7.0-rc2
because ofctr
)$ k3d import-images --cluster test-cluster nginx:local redis:v2
/var/run/docker.sock
to have access to the docker daemon/APIdocker save nginx:local redis:v2 -o /images/images.tar
(API variant)/iamges/images.tar
is then available to the k3d nodesctr image import /images/images.tar
in every k3d node to import the images into each node's containerd image cacheExplanation
I chose this approach, since I had much trouble with the other approach (saving the stream to a tarball on the fly) and because I think that we can save bandwidth and avoid possible network latency by working directly on the docker host (which might be remote) instead of saving from docker host to local host and copy the tarball back.
The drawback is, that we'll have to maintain the additional docker image as well, though it's really small.
Possible TODOs
--rm
or--no-rm
flag to enable/disable automatic removal of the tarball--no-remove, --no-rm, --keep, -k
flag to disable automatic removal--all-cached
(or similar) flag to directly import all tarballs that are already in the/images
directory--from-tar
flag to import from a tarball that you have saved locally (branching before we create the helper container)FYI @andyz-dev