The Container Life Cycle
Containers are crafted from their base images. The container inherits the filesystem of the image by creating a thin read/write layer on top of the image layers' stack. The base images stay intact, and no changes are made to them. All your changes happen in that top layer of the container. For example, say you create a container of ubuntu: 14.08
. This image does not have the wget
package in it. When you install the wget
package, you actually install it on the top layer. So, you have a layer for the base image, and on top of it, another layer for wget
.
If you install the Apache
server as well, it will be the third layer on top of both of the previous layers. To save all your changes, you need to commit all these changes to a new image because you cannot write over the base image. If you do not commit the changes to a new image, these changes will be deleted with the container's removal.
The container undergoes many other states during its life...