How to specify an iterator in the volume path when using docker-compose to scale up service?

前端 未结 1 1109
盖世英雄少女心
盖世英雄少女心 2021-02-08 14:47

Background: I\'m using docker-compose in order to place a tomcat service into a docker swarm cluster but I\'m presently struggling with how I would approach the

1条回答
  •  误落风尘
    2021-02-08 15:11

    You should really NOT log to the filesystem, and use a specialized log management tool like graylog/logstash/splunk/... instead. Either configure your logging framework in Tomcat with a specific appender, or log to sysout and configure a logging driver in Docker to redirect your logs to the external destination.

    This said, if you really want to go the filesystem way, simply use a regular unnamed volume, and then call docker inspect on your container to find the volume's path on the filesystem :

    [...snip...]
    "Mounts": [
        {
            "Type": "volume",
            "Name": "b8c...SomeHash...48d6e",
            "Source": "/var/lib/docker/volumes/b8c...SomeHash...48d6e/_data",
            "Destination": "/opt/tomcat/logs",
    [...snip...]
    

    If you want to have nice-looking names in a specific location, use a script to create symlinks.

    Yet, I'm still doubtfull on this solution, especially in a multi-host swarm context. Logging to an external, specialized service is the way to go in your use case.

    0 讨论(0)
提交回复
热议问题