Can I mount the same volume in multiple docker containers

I need to share application logs with the volume installed. I want to install one volume on all docker containers to save logs. Is it possible? Will this work with the application in each container?

docker run -d --name C1 -v /home/ubuntu/logs:/usr/local/apache/htdocs/ httpd docker run -d --name C2 -v /home/ubuntu/logs:/etc/app/logs my-docker-image:latest docker run -d --name C3 -v /home/ubuntu/logs:/usr/logs TestImage:latest 
+5
source share
3 answers

Yes, you can add the same location as volumes to many docker containers.

Alternatively, you can use --volumes-from to mount your log directory in one container that is not actually using any application, and then use volumes from that container in other containers without repeating paths everywhere.

Worth reading Dockers

+8
source

I mount the same directory into several containers, but for reading, not writing (if your logs are written inside containers. I think that if they write to different files, it should work ..

+1
source

Yes it is possible. Before you do this, just do a little research, “Why do you want to do this?”

+1
source

Source: https://habr.com/ru/post/1265604/


All Articles