<p>I have an Image which i should add a dependency to it. Therefore I have tried to change the image when is running on the container and create new Image.
I have follow <a href="https://www.techrepublic.com/article/how-to-commit-changes-to-a-docker-image/" rel="nofollow noreferrer">this article</a> with the following commands after :</p>

<pre><code>kubectl run my-app --image=gcr.io/my-project-id/my-app-image:v1 --port 8080
kubectl get pods
kubectl exec -it my-app-container-id -- /bin/bash
</code></pre>

<p>then in the shell of container, i have installed the dependency using "pip install NAME_OF_Dependncy".
Then I have exited from the shell of container and as it have been explained in the article, i should commit the change using this command :</p>

<pre><code>sudo docker commit CONTAINER_ID nginx-template
</code></pre>

<p>But I can not find the corresponding command for Google Kubernetes Engine with <strong>kubectl</strong></p>

<p>How should i do the commit in google container engine?</p>

<p>As with K8s Version 1.8. There is no way to do Hot Fix changes directly to the images.For example, Committing new image from running container. If you still change or add something by using <code>exec</code>  it will stay until the container is running. It's <strong>not best practice</strong> in K8s eco-system. </p>

<p><strong>The recommended</strong> way is to use <strong>Dockerfile</strong> and customise the images according to the necessity and requirements.After that, you can push that images to the registry(public/ private ) and deploy it with K8s manifest file.</p>

<p><strong>Solution to your issue</strong> </p>

<ul>
<li>Create a Dockerfile for your images. </li>
<li>Build the image by using Dockerfile. </li>
<li>Push the image to the registry.</li>
<li>write the deployment manifest file as well service manifest file.</li>
<li>apply the manifest file to the k8s cluster.</li>
</ul>

<p>Now If you want to change/modify something, you just need to change/modify the Dockerfile and follow the remaining steps.  </p>

<p>As you know that containers are a short living creature which does not have persist changed behaviour ( modified configuration, changing file system).Therefore, It's better to give new behaviour or modification at the Dockerfile.</p>

<p><strong>Kubernetes Mantra</strong><br>
Kubernetes is Cloud Native product which means it does not matter whether you are using Google Cloud, AWS or Azure. It needs to have consistent behaviour on each cloud provider.  </p>
