kindcontainer icon indicating copy to clipboard operation
kindcontainer copied to clipboard

Option to run K3S container with --docker flag

Open nicoloboschi opened this issue 3 years ago • 5 comments

It may be useful to let the user configure the k3s server to run within the --docker.

With this flag the local docker images are available to the k3s pods

nicoloboschi avatar Oct 26 '22 19:10 nicoloboschi

Hey @nicoloboschi,

thanks for your suggestion!

I must admit I'm no expert on running k3s w/ docker, so I'm trying to understand it some more here...

Reading the docs seems to imply that --docker would just make k3s use cri-dockerd instead of containerd, so in consequence a docker daemon running inside the container would be in charge of running the containers for the pods, correct?

Would you then use the docker wormhole pattern to make k3s use the external docker daemon?

dajudge avatar Oct 27 '22 06:10 dajudge

I'm not an expert either but yes, I would like to leverage the docker daemon of the host, for example to use local docker images.

Actually I already started the server with the --docker flag but still not able to read through the host docker registry.

I ended up with saving/loading the docker image but it's not an optimal solution.

To give you more context: I'm building an operator and in the integration tests I need the operator's image. I think this library may revolutionize the way the operators are tested 🚀

nicoloboschi avatar Oct 27 '22 07:10 nicoloboschi

I have been also using K3S from this project and I was not able to deploy a locally build docker image with JIB, it would be great to support it, so we can run integration tests from within the cluster. Is there anything I can do to helper ?

vietj avatar Sep 08 '23 06:09 vietj

@vietj in this project we run the integration tests using k3 (w/ kindcontainer). Since it's not possible to set the current context to the k3s docker, we inject the image using load + import.

Here's the code: https://github.com/datastax/kaap/blob/main/tests/src/test/java/com/datastax/oss/kaap/tests/env/k3s/AbstractK3sContainer.java

Still not the best solution in terms of efficiency but it works

nicoloboschi avatar Sep 08 '23 06:09 nicoloboschi