Skip to content

Instantly share code, notes, and snippets.

@hoogenm
Created February 21, 2022 20:48
Show Gist options
  • Save hoogenm/363fa6abfe4796ef6933ff4b113e52dc to your computer and use it in GitHub Desktop.
Save hoogenm/363fa6abfe4796ef6933ff4b113e52dc to your computer and use it in GitHub Desktop.
Docker Image to ContainerD
d2c() {
docker save "$1" | ctr image import -
}
@hoogenm
Copy link
Author

hoogenm commented Feb 21, 2022

Usage, to copy image tagged mycompany/mycontainer:v3 from local(ly built) Docker image to local ContainerD images:

source d2c.sh
d2c mycompany/mycontainer:v3

To then use the image in a Kubernetes yaml definition without pulling from registry, use the (same) tag, and imagePullPolicy: Never. With kubectl run use --image-pull-policy=Never to prevent pulling from registry.

For Kubernetes, works on local node only (i.e. only when pod is scheduled on the same node where d2c was executed, e.g. single node, or force scheduling of pod on same node, or have d2c executed on multiple nodes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment