Ravindra BagaleCourses & study guides मराठी

Chapter 6: Why Docker, Images and How a Container Is Created

6.7 Way 4 — docker commit, emergency only

docker commit badge-php badge-php:emergency

This copies the changed container into a new image. Operations — the server-side employee — types it only to salvage a lab that is about to be deleted, after a package was installed inside the running container and the Dockerfile does not have that line yet. It is an emergency, not the way you ship.

Suppose we are on the laptop, the Instagram-style badge container has a one-off package, and the container will be removed before the Dockerfile is fixed. What you see: a new image id and the name badge-php:emergency.

Why this is an emergency, not a habit. The image has no Dockerfile. The next person cannot rebuild it. A secret typed inside the container can sit in a layer. Netflix-style rollback wants a tag that came from a file in Git, not from a late-night copy of a live container.

Prefer way 2: write the RUN or COPY into the Dockerfile and docker build again. Use docker commit only to salvage a lab you are about to lose, then rebuild a proper image the same day.

Ravindra Bagale's Tip

Khup students container madhe apt install karun docker commit final image mhanun dethat. Dockerfile shivay rebuild nahi. Bilkul visru naka!

Ravi Sir's Cards for this lesson

मराठी cards