For my opinion, a container is a running instance of image. What if the container is crashed, for example run sudo rm -f /
delete all the stuffs, is the docker image still OK?
Asked
Active
Viewed 1,316 times
0

yalei du
- 697
- 7
- 13
-
An instance of an image is a container and you can have some instances of the same image so the Image still OK. Images are immutables. – Pau Aug 05 '16 at 18:54
-
Although it partly depends on where the hypothetical `rm -rf /` happens -- if the entire host is wiped, you will lose both the containers and the images. However, if the images have been pushed to a remote repo and/or you have the Dockerfiles, they should be easily recreated _if_ they have been treated as immutable (which isn't always the case). So your best plan is to have a repo with a Dockerfile and any (up-to-date) support files available. If the container crashes, you may lose any uncommitted changes, but you shouldn't set up your containers/images that way in any case. – ldg Aug 05 '16 at 20:19
1 Answers
3
No effect for image in both cases. Look if you create new container via docker run, virtually new layer
When you create a new container, you add a new, thin, writable layer on top of the underlying stack. This layer is often called the “container layer”. All changes made to the running container - such as writing new files, modifying existing files, and deleting files - are written to this thin writable container layer. The diagram below shows a container based on the Ubuntu 15.04 image. src
This stackopverflow discussion may be helpful as well: Docker image vs container

Community
- 1
- 1

aholbreich
- 4,951
- 2
- 23
- 38