Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker mount namespace

Tags:

docker

When i mount $docker run -v /tmp:/tmp -ti ubuntu /bin/bash for the running container that uses the filesystem of the host . When i close the above container from exit command and i link the above container id with the new $docker run --volumes-from="closed container id" -ti ubuntu /bin/bash this as well uses /tmp files in the newly running container.how is this possible that even after closed the container it is still could be referred in other container.please explain me in a better way what is happening in docker.

like image 994
Sowndarya K Avatar asked Apr 14 '26 03:04

Sowndarya K


2 Answers

how is this possible that even after closed the container it is still could be referred in other container.please explain me in a better way what is happening in docker.

This is an expected behavior, because the you have mapped volume -v /tmp:/tmp on the first instance, which means you have mapped /tmp on your host OS to /tmp inside the container. Now any changes you make within the container remains on the host OS which is accessible by the second or third instance unless the <container id> is removed.

The container exists unless its removed with docker rm <container id>. You can get the <container id> from docker ps -a, which returns the list of all the containers which are running and have been exited AND not been removed.

like image 138
askb Avatar answered Apr 23 '26 10:04

askb


Check Container Solution's Understanding Volumes in Docker

like image 32
Quanlong Avatar answered Apr 23 '26 10:04

Quanlong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!