Why there is different container Id originating from the same Docker Image from the same command path as we can see in the picture?
- What can be the specific case where I need several containers from the same images?
- Do 'each' of these containers consume the equivalent size of the image?
- I have noticed that the new container Id is listed once I reboot the system. What is the best approach to manage the scenario and run using the same container Id?
- Does docker commit mean same as persistent volumes in docker? If no, how do they differ?
I couldn't find answers on stackoverflow. If the question is redundant please remove.
CodePudding user response:
Why there is different container Id originating from the same Docker Image from the same command path
To differentiate different running containers.
What can be the specific case where I need several containers from the same images?
For example you want to run two sshd services - one on port 22 and other on port 23. Or any two same services.
Or there are two developers using one machine, and both are compiling their projects in a docker at the same time.
Etc.
Do 'each' of these containers consume the equivalent size of the image?
The base layers share the disc space. Each container has its own private filesystem mounted "on top" other layers. They consume only the changes they made. They share the image on top they were built. You may want to research squashfs and https://docs.docker.com/storage/storagedriver/ .
Each processes inside containers have separate process space.
What is the best approach to manage the scenario and run using the same container Id?
Use NAMES.
Does docker commit mean same as persistent volumes in docker?
No.
If no, how do they differ?
It creates a new docker layer, and commits that as a new docker image.
Image = tar.gz with the files.
Container = one instance of running image.