Now I wish to create an image out of that container to record all those changes in a single image.
That is generally the wrong way to go about it: you should create your image using a Dockerfile
, and then deploy it to Kubernetes to test it. You should treat your running container as "read-only" and only makes changes by updating your Dockerfile (or similar) and re-building the image.
Doing things this way ensures that you are able to re-create the image, and allows you to use version control on the Dockerfile so that you have a record of what changes you made and why.
Is there a way to something similar but considering the container is managed inside a pod of k8s?
The only way to create an image* from the running container would be to use docker commit
. There is no Kubernetes mechanism for performing this action. You'll need to log into the Kubernetes node on which your container is running and run docker commit
there, and then potentially docker push
the image to a repository if you intend on running it elsewhere.
*: That's a bit of a simplification. E.g., you could use something like tar
to export the filesystem, and once you have that there are various way to unpack it into an image.