Docker Community Forums

Share and learn in the Docker community.

NFS, volumes, persistent consolidated application log files

Docker 18.09.03, UCPv3.1.4 using swarm not K8s.

I’ve got an external drive where all containers need to keep their log files. These are plain text files (hundreds of them) from hundreds of applications. The application log files need to be in one place for the moment so we have an audit trail that’s searchable at any given time.

I created a named volume in the Dockerfile (VOLUME $HOME/log/dbs). Great, we never lose our log file for this application, but it doesn’t give us a consolidated place to view all log files outside the swarm.

I have an NFS mnt point. How do I get the log files to save to the NFS mout as well as what it’s doing now?

I created a volume called testinglogs. How do I point the log files that are inside $home/log/dbs to also save out to the testinglogs volume? I’m not utilizing docker-compose but UCP and the Dockerfile for the application. Is this not the right way? The volume information is:

docker volume inspect testinglogs
[
{
“CreatedAt”: “2019-05-28T16:13:20-07:00”,
“Driver”: “local”,
“Labels”: {},
“Mountpoint”: “/var/lib/docker/volumes/testinglogs/_data”,
“Name”: “testinglogs”,
“Options”: {
“device”: “:/volume1/Docker”,
“o”: “addr=dockershare.our.domain.com,rw,sync,actimeo=0”,
“type”: “nfs”
},
“Scope”: “local”
}
]

I’ve read the docs but it’s not clear what my next steps are. Any references to additional information or any tips are very appreciated.

first I would recommend using logging collections tools like the ELK stack instead of logging directly to the filesystem. With the filesystem approach you risk filling the filesystem, and breaking all applications.

Regarding your current approach, instead of using a named volume, you can just use a bind mount. The nfs volume should be mounted in the same location on each host. The source for the volume will then be the path to the nfs mount /nfs/share/logs and the target will be the path within the container /app/logs.

This approach also keeps the logs outside of your /var/libs/docker mount, which you don’t want to fill up by accident.

hope this helps

You might want to take a look at https://github.com/stefanprodan/swarmprom