Image and Container
What is the difference
Image
A image provides all conditions the project needed, including
- A cut-down OS
- Third-party libraries
- Application files
- Environment variables
Container
- Provides an isolated environment
- Can be stopped & restarted
- Is just a process!
A container is just a process created from a image, different containers are isolated!
Now let's start new containers to have a test.
bash
docker run -it ubuntu
root@11c5eb2fa1a2:/#
1
2
3
2
3
Then start a new terminal session, run a new container
bash
docker run -it ubuntu
root@c0735cd1e137:/#
1
2
3
2
3
Different containers have different id! And their file system are isolated.
bash
root@11c5eb2fa1a2:/# cd ~
root@11c5eb2fa1a2:~# touch test.txt
root@11c5eb2fa1a2:~# ls
test.txt
root@11c5eb2fa1a2:~#
root@c0735cd1e137:/# cd ~
root@c0735cd1e137:~# ls
root@c0735cd1e137:~#
# nothing here!
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11