Background: I use docker-compose to host the tomcat service in a cluster of a swock cluster, but I am now struggling with how I will access the registration directory, given that I want to scale the service, but keep the logging directory unique.
Consider a (explicitly) compiled docker composition that simply launches tomcat and mounts a file registration system in which you can record logs.
version: '2' services: tomcat: image: "tomcat:latest" hostname: tomcat-example command: /start.sh volumes: - "/data/container/tomcat/logs:/opt/tomcat/logs,z"
Version
- docker 1.11
- docker-compose 1.7.1
- API version 1.21
Problem: I want to understand how I would like to insert a variable in the "volume" log path so that the log directory is unique for each instance of the scaled service
eg,
volumes: - "/data/container/tomcat/${container_name}/logs:/opt/tomcat/logs,z"
I see that based on the name of the project (or the directory I am in) the name of the container is actually known, so can I use this?
for example, setting the project name to "tomcat" and running docker-compose scale tomcat=2 , I will see the following containers.
- hostname / tomcat _1
- hostname / tomcat _2
So I can use this as a variable in the logging volume, other suggestions or approaches are welcome. I understand that I can just specify the relative path and let container_id take care of this, but now if I attach splunk or logstash to the logging devices, I will need to know which ones are really logging devices and not the basic f / s containers. However, ideally, I am looking for a specific absolute path here.
Thanks in advance dockers! R.
docker docker-compose docker-swarm scale volume
Snowy
source share