How to save image of running pod on aks like "docker commit"

Sachin 5 Reputation points
2023-02-24T11:40:25.41+00:00

Hi,

AKS nodes are now with CRI plugins so I cannot do docker commit to save images of running pod on nodes.

Can anyone help on how to save image of running pods on AKS? Any alternative?

Azure Kubernetes Service
Azure Kubernetes Service
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
2,457 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Tech-Hyd-1989 5,816 Reputation points
    2023-02-24T14:52:41.27+00:00

    Hello @Sachin
    Goodday!

    Alternatively, you can use Azure Container Registry (ACR) to store your Docker images. AKS supports the Docker image format, and you can integrate it with ACR for private storage of your Docker images. To create a private image store, see Azure Container Registry.
    I think you can use kubectl cp command to copy files from a running container to your local machine, including the Dockerfile and any other files you need to build the image.

    Use the az acr build command to build and push the image to an Azure Container Registry (ACR). This command builds the image from a Dockerfile, then pushes the image to an ACR.

    Basically, Identify the pod and container you want to save, then use the below command to copy

    kubectl cp <pod-name>:<container-path> <local-path>

    Create a Dockerfile that includes the copied files. Build the Dockerfile and push the image to an ACR using the az acr build command.

    az acr build --image <image-name>:<tag> --registry <acr-name> --file <path-to-dockerfile> <path-to-context>

    I believe that's it. Feel free to reach out for any queries.

    If this does answer your question, please accept it as the answer as a token of appreciation.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.