https://rancher.com/ logo
Title
p

polite-engineer-55788

08/19/2022, 3:12 AM
Is there a way to export images from an existing k3d based cluster
w

wide-garage-9465

08/19/2022, 6:45 AM
You mean the ones saved in the nodes? I'd go for
docker exec <...> ctr image save
followed by
docker cp
. Obviously different if the image is in a registry or a pod inside the cluster.
p

polite-engineer-55788

08/19/2022, 4:10 PM
You mean the ones saved in the nodes?
yeah the ones we add to the node after deploying applications
its more for demoing in disconnected mode
@wide-garage-9465 have you used to nerdctl with k3d ? finding ways to save the images on a cluster for doing air-gapped install
w

wide-garage-9465

08/31/2022, 1:41 PM
I'd love to actually use k3d with pure containerd. Tried to use the nerdctl codebase for this back then, but it's incredibly complex. If I find the time (and funding), this will be the prime feature in v6 🚀
🙌🏽 1
p

polite-engineer-55788

08/31/2022, 1:42 PM
I’d go for docker exec <...> ctr image save followed by docker cp.
got any sample repo or script demoing this, I assume the exec should be to tools node ?
w

wide-garage-9465

08/31/2022, 1:44 PM
Nope, but I can try to create something if I have the time
Exec to the node where the image is stored
So can you describe the flow up to this point? Building the image, getting it into the cluster, deploying the app?
p

polite-engineer-55788

08/31/2022, 1:48 PM
• Setup k3d • Run script do prepare the demo infra this will have kube dpeloyments ( I images I want to cache) • Run custom app ( includes II set of images to cache) • run the caching script • Disconnect from install • Do step All the steps as before w/o internet
ideally it would be nice for k3d to provide such command as it will be very usaeful for developers
if I am able write a script and do caching, will try to convert that to a k3d command ( possible future contrib)
❤️ 1
w

wide-garage-9465

08/31/2022, 2:00 PM
Okay, I'm trying to fully understand this. You create a k3d cluster and deploy something to it, which pulls the images from e.g. DockerHub into the k3d nodes. Then you want to export those images from the k3d nodes to your host machine. Next, you want to create a new k3d cluster and import all the locally saved images, so that you can deploy again without having to pull the images from DockerHub again?
p

polite-engineer-55788

08/31/2022, 2:20 PM
thats right
technically you turn off your internet on your machine
w

wide-garage-9465

08/31/2022, 2:21 PM
So why not just pull the images via docker pull beforehand and then use k3d image import?
p

polite-engineer-55788

08/31/2022, 2:45 PM
yeah thats the best option 😄
@wide-garage-9465 I was trying to do
ctr image export
and my current
ctr ls -q
shows the following output
/ # ctr images ls -q
<http://docker.io/bitnami/memcached:1.6.9-debian-10-r114|docker.io/bitnami/memcached:1.6.9-debian-10-r114>
<http://docker.io/bitnami/memcached@sha256:6b10107669332f3f68b659f3f13ce33c869d2dcaacdd64fd3e6cf0a7d98b9cd7|docker.io/bitnami/memcached@sha256:6b10107669332f3f68b659f3f13ce33c869d2dcaacdd64fd3e6cf0a7d98b9cd7>
<http://docker.io/bitnami/mongodb:5.0.8-debian-10-r24|docker.io/bitnami/mongodb:5.0.8-debian-10-r24>
<http://docker.io/bitnami/mongodb@sha256:8683a10d1e24dcb1053913f6e6acaa8b64001788b76ee8ccb2cd46149e4b50a3|docker.io/bitnami/mongodb@sha256:8683a10d1e24dcb1053913f6e6acaa8b64001788b76ee8ccb2cd46149e4b50a3>
<http://docker.io/bitnami/postgresql:11.11.0-debian-10-r62|docker.io/bitnami/postgresql:11.11.0-debian-10-r62>
<http://docker.io/bitnami/postgresql@sha256:044559541242562493957ab02c3ff7a9a55b8571aa2c8d98e0557b189c2d3968|docker.io/bitnami/postgresql@sha256:044559541242562493957ab02c3ff7a9a55b8571aa2c8d98e0557b189c2d3968>
<http://docker.io/drone/drone-runner-docker:1.8.1|docker.io/drone/drone-runner-docker:1.8.1>
<http://docker.io/drone/drone-runner-docker@sha256:137e79c5e23c54cab6d4632f7f5371dff9aec76c3fd9819296ad711151e888b4|docker.io/drone/drone-runner-docker@sha256:137e79c5e23c54cab6d4632f7f5371dff9aec76c3fd9819296ad711151e888b4>
<http://docker.io/drone/drone-runner-kube:1.0.0-rc.3|docker.io/drone/drone-runner-kube:1.0.0-rc.3>
<http://docker.io/drone/drone-runner-kube@sha256:4359bf2bb3dc3a00615b5ee4e0ba5e84a52f835a402b2b5497804da73cba14e9|docker.io/drone/drone-runner-kube@sha256:4359bf2bb3dc3a00615b5ee4e0ba5e84a52f835a402b2b5497804da73cba14e9>
<http://docker.io/drone/drone:2.12.1|docker.io/drone/drone:2.12.1>
<http://docker.io/drone/drone@sha256:cf93331c3ed2a704239e7b84761b80806eb6bc319caf960234c4a21a4bd5d568|docker.io/drone/drone@sha256:cf93331c3ed2a704239e7b84761b80806eb6bc319caf960234c4a21a4bd5d568>
<http://docker.io/gitea/gitea:1.17.0|docker.io/gitea/gitea:1.17.0>
<http://docker.io/gitea/gitea@sha256:75e556f3561804e9bcca0d860c2f0c475f1c21581f9aaf344e1e232f9aa4862d|docker.io/gitea/gitea@sha256:75e556f3561804e9bcca0d860c2f0c475f1c21581f9aaf344e1e232f9aa4862d>
<http://docker.io/kameshsampath/drone-tutorial-gitea-helper@sha256:2f9e10ed31a6cc8e1e24d6493028c63a325c029f9e63eb47d4bf75828c540dba|docker.io/kameshsampath/drone-tutorial-gitea-helper@sha256:2f9e10ed31a6cc8e1e24d6493028c63a325c029f9e63eb47d4bf75828c540dba>
<http://docker.io/kameshsampath/nexus3-config:latest|docker.io/kameshsampath/nexus3-config:latest>
<http://docker.io/kameshsampath/nexus3-config@sha256:573819ceb237055c26e14083577121d72040e87e51988a3bc2cc61dace7b1b15|docker.io/kameshsampath/nexus3-config@sha256:573819ceb237055c26e14083577121d72040e87e51988a3bc2cc61dace7b1b15>
<http://docker.io/kameshsampath/nexus3:3.41.0-01|docker.io/kameshsampath/nexus3:3.41.0-01>
<http://docker.io/kameshsampath/nexus3@sha256:69524923e4e4598d19cb6841b065f9adf3e479a9484d44e1c71bc5c326a2b954|docker.io/kameshsampath/nexus3@sha256:69524923e4e4598d19cb6841b065f9adf3e479a9484d44e1c71bc5c326a2b954>
<http://docker.io/library/docker:20-dind|docker.io/library/docker:20-dind>
<http://docker.io/library/docker@sha256:ccadddf7b5885ebd0eaffec72be1b38cb66c6bca215d54a2820708137eb52357|docker.io/library/docker@sha256:ccadddf7b5885ebd0eaffec72be1b38cb66c6bca215d54a2820708137eb52357>
<http://docker.io/litmuschaos/curl:2.10.0|docker.io/litmuschaos/curl:2.10.0>
<http://docker.io/litmuschaos/curl@sha256:b8c8a8fa772126b681f4b06672130a60d518502497415345e5a1c2af32a32265|docker.io/litmuschaos/curl@sha256:b8c8a8fa772126b681f4b06672130a60d518502497415345e5a1c2af32a32265>
<http://docker.io/litmuschaos/litmusportal-frontend:2.11.0|docker.io/litmuschaos/litmusportal-frontend:2.11.0>
<http://docker.io/litmuschaos/litmusportal-frontend@sha256:2a2d28ac1b1cbe2543ab85ac93fb70874114d0445378b483c8455fa4105d57a0|docker.io/litmuschaos/litmusportal-frontend@sha256:2a2d28ac1b1cbe2543ab85ac93fb70874114d0445378b483c8455fa4105d57a0>
<http://docker.io/rancher/klipper-helm:v0.7.3-build20220613|docker.io/rancher/klipper-helm:v0.7.3-build20220613>
<http://docker.io/rancher/klipper-helm@sha256:6a8e819402e3fdd5ff9ec576174b6c0013870b9c0627a05fa0ab17374b5cf189|docker.io/rancher/klipper-helm@sha256:6a8e819402e3fdd5ff9ec576174b6c0013870b9c0627a05fa0ab17374b5cf189>
<http://docker.io/rancher/klipper-lb:v0.3.5|docker.io/rancher/klipper-lb:v0.3.5>
<http://docker.io/rancher/klipper-lb@sha256:02f8cb41d53fe08b5726a563ce36c3675ad7f2694b65a8477f6a66afac89fef7|docker.io/rancher/klipper-lb@sha256:02f8cb41d53fe08b5726a563ce36c3675ad7f2694b65a8477f6a66afac89fef7>
<http://docker.io/rancher/local-path-provisioner:v0.0.21|docker.io/rancher/local-path-provisioner:v0.0.21>
<http://docker.io/rancher/local-path-provisioner@sha256:1da612c913ce0b4ab82e20844baa9dce1f7065e39412d6a0bb4de99c413f21bf|docker.io/rancher/local-path-provisioner@sha256:1da612c913ce0b4ab82e20844baa9dce1f7065e39412d6a0bb4de99c413f21bf>
<http://docker.io/rancher/mirrored-coredns-coredns:1.9.1|docker.io/rancher/mirrored-coredns-coredns:1.9.1>
<http://docker.io/rancher/mirrored-coredns-coredns@sha256:35e38f3165a19cb18c65d83334c13d61db6b24905f45640aa8c2d2a6f55ebcb0|docker.io/rancher/mirrored-coredns-coredns@sha256:35e38f3165a19cb18c65d83334c13d61db6b24905f45640aa8c2d2a6f55ebcb0>
<http://docker.io/rancher/mirrored-library-busybox:1.34.1|docker.io/rancher/mirrored-library-busybox:1.34.1>
<http://docker.io/rancher/mirrored-library-busybox@sha256:4b4c98fec18de30435adaea7b2e78c199e4b8cf6c7c96584e912afd72101365c|docker.io/rancher/mirrored-library-busybox@sha256:4b4c98fec18de30435adaea7b2e78c199e4b8cf6c7c96584e912afd72101365c>
<http://docker.io/rancher/mirrored-library-traefik:2.6.2|docker.io/rancher/mirrored-library-traefik:2.6.2>
<http://docker.io/rancher/mirrored-library-traefik@sha256:ad2226527eea71b7591d5e9dcc0bffd0e71b2235420c34f358de6db6d529561f|docker.io/rancher/mirrored-library-traefik@sha256:ad2226527eea71b7591d5e9dcc0bffd0e71b2235420c34f358de6db6d529561f>
<http://docker.io/rancher/mirrored-metrics-server:v0.5.2|docker.io/rancher/mirrored-metrics-server:v0.5.2>
<http://docker.io/rancher/mirrored-metrics-server@sha256:48ecad4fe641a09fa4459f93c7ad29d4916f6b9cf7e934d548f1d8eff96e2f35|docker.io/rancher/mirrored-metrics-server@sha256:48ecad4fe641a09fa4459f93c7ad29d4916f6b9cf7e934d548f1d8eff96e2f35>
<http://docker.io/rancher/mirrored-pause:3.6|docker.io/rancher/mirrored-pause:3.6>
<http://docker.io/rancher/mirrored-pause@sha256:74c4244427b7312c5b901fe0f67cbc53683d06f4f24c6faee65d4182bf0fa893|docker.io/rancher/mirrored-pause@sha256:74c4244427b7312c5b901fe0f67cbc53683d06f4f24c6faee65d4182bf0fa893>
<http://ghcr.io/dexidp/dex:v2.30.2|ghcr.io/dexidp/dex:v2.30.2>
<http://ghcr.io/dexidp/dex@sha256:27cf2e8644f2ea1ebc6de711b0ace4b5ee2d1f442e148eabbaa8c68308062475|ghcr.io/dexidp/dex@sha256:27cf2e8644f2ea1ebc6de711b0ace4b5ee2d1f442e148eabbaa8c68308062475>
public.ecr.aws/docker/library/redis:7.0.4-alpine
public.ecr.aws/docker/library/redis@sha256:dc1b954f5a1db78e31b8870966294d2f93fa8a7fba5c1337a1ce4ec55f311bc3
<http://quay.io/argoproj/argocd:v2.4.9|quay.io/argoproj/argocd:v2.4.9>
<http://quay.io/argoproj/argocd@sha256:579573fc13129acd8ff7369f76634bbb83fd427343d24dc28bec02d7eab9d0fb|quay.io/argoproj/argocd@sha256:579573fc13129acd8ff7369f76634bbb83fd427343d24dc28bec02d7eab9d0fb>
<http://quay.io/argoprojlabs/argocd-image-updater:v0.12.0|quay.io/argoprojlabs/argocd-image-updater:v0.12.0>
<http://quay.io/argoprojlabs/argocd-image-updater@sha256:7448a7b84302c8344d5f75114912df5e1a38d28db7e7f16af639909cefde431f|quay.io/argoprojlabs/argocd-image-updater@sha256:7448a7b84302c8344d5f75114912df5e1a38d28db7e7f16af639909cefde431f>
sha256:09ae745dd6773c1c14d6d67cbb8bdf9118f6261935403c653e212ffbbbd61843
sha256:107397058fbe3bd4229b121abe9985135319ff80687e3b1094c460b46f1102f7
sha256:1d64d3e888a2146b25c264f20dd929cba838bbed44082a5d3beac74c9e4b309c
sha256:2ef507d0470ecf849d69dba8f5f48bbeb0aaef90c5fe1f2785b6ae52565f264e
sha256:73d04c93d67176a02b94335b2f9dbd84d877151bd5be4d349c493c9d96d04696
sha256:7aa1936c6c05e353b9530159141021b651823109bcb9c23ab95f26f4c1630de0
sha256:7b63c40f7ccf49f9843ddedb99dace07196e5eee0f5cbff6eaac874ad969cebb
sha256:7d46a07936af93fcce097459055f93ab07331509aa55f4a2a90d95a3ace1850e
sha256:878cd02d89b44b8e65d04f27b7085a7b085dc60fc62c08717ec1abb32a48e0f8
sha256:8b36f02b5afbd90d9c6de3646d53b81930657d2a80a25e40cb98387f9989d9fd
sha256:941e9d22811e7c1b68f7d753caa7b649c7f2e3125a6a0b10d98e5e42d2a573b2
sha256:ac051582d7a2857d0a88d19dae23a21c2bea136ed58d7bebb4715a80304ba1e5
sha256:b12bbec1f4615cea87fe3d5ba5535aefc6ee875fccc642767467293a93154aff
sha256:b524fed054100f225abae05029e3eb4efda71508fad3a9a32517357cf11bf7e8
sha256:b52d46af481d20081dcf314023a92679ce0dd2618349198ea680122be237c49f
sha256:c900296db1f85d7f85d72d6043e04c5e039777b65eb1fb68dd9e1cb3f63de13a
sha256:cd0eb92a37da5c5f060954d7e401d60153edf8603211707eb35b100b1cb95af4
sha256:cf00fc9bb0c19883ee7fcff78701583b3174e06519d377c9de29b8c10be05e58
sha256:d010323f37d52c6ef81220c6ea8a799bd915021f18b7dc86b470eb523d00113d
sha256:d19a22f3affb5ac306722c390418af265526803ca0390513f7f90f47e43b8403
sha256:dfdf9d0e530a0d3cc727e54f199ac15bd66eafd475b395412cd7c2965f1d26a3
sha256:e561865175229228a31c25e182ec238f4e3d06369ad845527588534dafed5d61
sha256:ec3aa302ca06aae89f459b5656d4f1be37cbf3081b8033b3c821c31e8cb7da31
sha256:f40c41555cd4d25d273942094af1267824b9d3e901fdb7c60565dcb6175955df
sha256:fe8bc53de6e47500407a30e6d1afaebdd813642b45d5a4ed15e849a042259bf9
how do I filter it to get only image names like
<http://docker.io/foo/bar|docker.io/foo/bar>:<tag>
so that I can use that as argument to export and cache those images for air gapped demos
sorry I am bit new to
ctr
w

wide-garage-9465

09/17/2022, 10:02 AM
Not sure if there's a filter flag... But what about
| grep "<http://docker.io|docker.io>"
?
p

polite-engineer-55788

09/17/2022, 10:03 AM
yeah thats what I am trying
this works
ctr images ls -q | grep -v -E '^sha256'
and I am not sure if I need to load both the
sha
references as well as the ones with just tags
a better one
ctr images ls -q | grep -v -E 'sha256:'
so I just get image name and tag
exporting images from existing cluster seem to be tricky
from the server node I did
set -- $(ctr images ls -q | grep -v -E 'sha256'
and then
ctr images export out.tar "$@"
that seem to fail with error
ctr: content digest sha256:1c5305261dd85058cd0b817b6e2524bbec8ab19e8665868f1baaa29495cf5eba: not found
kind of trying bulk export