Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker mount namespace to share between containers

How the mount namespace using container's id is utilized for sharing files in other containers even after exiting from the original container?

like image 840
Sowndarya K Avatar asked Oct 28 '25 07:10

Sowndarya K


1 Answers

This is called a data colume container: see "Creating and mounting a data volume container"

$ docker create -v /dbdata --name dbdata training/postgres /bin/true
$ docker run -d --volumes-from dbdata --name db1 training/postgres
$ docker run -d --volumes-from dbdata --name db2 training/postgres

Here, even if the container db1 exits, db2 has still access to the shared voume dbdata.

dbdata is a data volume container that you don't "run" (there is no process running in it, only a shared volume of data); you "create" it only. (and you don't "exit" it either, since you never ran it)

like image 182
VonC Avatar answered Oct 31 '25 01:10

VonC



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!