Any way to tell where a file in overlay2 is used?

A swarm task does only provide details about the TaskSpecs, thus no details about the container it creates. Basicly it is impossible to gather the details from a master node.

You will have to connect to each node and execute following command to determin which path is owned by which container:

for container in $(docker ps --all --quiet --format '{{ .Names }}'); do 
  echo "/var/lib/docker/containers/$(docker inspect $container --format '{{.Id}}') = $container"
done

my bad, I concentrated on the container instead of the overlay2 folder. Let me see, if there is a way for that as well…

There is:

for container in $(docker ps --all --quiet --format '{{ .Names }}'); do 
  echo "$(docker inspect $container --format '{{.GraphDriver.Data.MergedDir }}' | sed 's#/\([^az]*\)\.*$##' ) = $container"
done

Merged, Workdir, UpperDir all share the same subfolder. So identifying any one of those helps to find the folder. The sed command should cut of the specific subfolder.

1 Like