How to set volume in running multiple docker container using docker socket api?

i have multiple docker containers in single host like,

  1. tomcat,

  2. elasticcsearch,

  3. postgresql,

and one is logstash,

  1. logstash.

From where i have to set volume or logs path to access from logstash docker container in single host, so how to do it.

please any suggestion for this issue?

Either you write all logs to host folder(s) using bind mount (doc), or you create volume(s) (doc) which are shared with logstash.

Alternatively check if logstash can not simply read the other containers stdout to fetch the logs.

Thanks bluepuma77,

i need define volume at run time (running containers) using docker socket api.

It isn’t supported in official Docker. Containers should be deletable any time so you could change the config and mount a new volume.

@ rimelek Thanks for reply,

Please suggest any way to handle this using docker socket.

Why?

Maybe read section “Shipping Docker Logs into ELK” from this article.

Since it is not supported in Docker, I can’t suggest anything. If your porblem is that you saved data in a container and now you want to move that to a volume, stop the container (so no data is written to the filesystem) use docker cp to copy the data out, remove the container and create a new container with a volume. Use docker cp to copy the data to the volume in the container, and start the container.

1 Like