Repository: google/docker-explorer

Issue:
Go from overlayFS ID to container ID
It would be useful to find a way to map an overlayFS ID to the container that actually used it.

e.g. given this path on a server running Docker:

`/mnt/docker/var/lib/docker/overlay2/6688ce711806faead06aae3ff534ab21183a087241d3a890741f0c3b437b179c/diff/var/tmp/malware`

Find out in which container 6688ce711806faead06aae3ff534ab21183a087241d3a890741f0c3b437b179c is being used.

Discussion:
codecov-io: # [Codecov](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=h1) Report
> Merging [#57](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=desc) into [master](https://codecov.io/gh/google/docker-explorer/commit/902f146bfc007537293319e745008883460bfaa9?src=pr&el=desc) will **increase** coverage by `0.03%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/google/docker-explorer/pull/57/graphs/tree.svg?width=650&token=lmhUb8WnfJ&height=150&src=pr)](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
+ Coverage   88.51%   88.55%   +0.03%     
==========================================
  Files           7        7              
  Lines         627      629       +2     
==========================================
+ Hits          555      557       +2     
  Misses         72       72
```


| [Impacted Files](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [tests.py](https://codecov.io/gh/google/docker-explorer/pull/57/diff?src=pr&el=tree#diff-dGVzdHMucHk=) | `100% <ø> (ø)` | :arrow_up: |
| [docker\_explorer/de.py](https://codecov.io/gh/google/docker-explorer/pull/57/diff?src=pr&el=tree#diff-ZG9ja2VyX2V4cGxvcmVyL2RlLnB5) | `78.26% <100%> (+0.31%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=footer). Last update [902f146...c1fabae](https://codecov.io/gh/google/docker-explorer/pull/57?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/docker_explorer/de.py b/docker_explorer/de.py
index d558e9c..286966f 100644
--- a/docker_explorer/de.py
+++ b/docker_explorer/de.py
@@ -257,6 +257,9 @@ class DockerExplorer(object):
           container_object.start_timestamp)
       container_json['image_name'] = container_object.config_image_name
 
+      if container_object.mount_id:
+        container_json['mount_id'] = container_object.mount_id
+
       result.append(container_json)
 
     return result


Test patch:
diff --git a/tests.py b/tests.py
index 48fef64..70363c4 100644
--- a/tests.py
+++ b/tests.py
@@ -176,6 +176,8 @@ class TestAufsStorage(DockerTestCase):
          '7968321274dc6b6171697c33df7815310468e694ac5be0ec03ff053bb135e768',
          'container_id':
          '7b02fb3e8a665a63e32b909af5babb7d6ba0b64e10003b2d9534c7d5f2af8966',
+         'mount_id':
+         'b16a494082bba0091e572b58ff80af1b7b5d28737a3eedbe01e73cd7f4e01d23',
          'start_date': '2017-02-13T16:45:05.785658',
          'image_name': 'busybox'}
     ]
@@ -339,6 +341,8 @@ class TestOverlayStorage(DockerTestCase):
          '5b0d59026729b68570d99bc4f3f7c31a2e4f2a5736435641565d93e7c25bd2c3',
          'container_id':
          '5dc287aa80b460652a5584e80a5c8c1233b0c0691972d75424cf5250b917600a',
+         'mount_id':
+         '974e2b994f9db74e1ddd6fc546843bc65920e786612a388f25685acf84b3fed1',
          'start_date': '2018-01-26T14:55:56.574924',
          'image_name': 'busybox:latest'}
     ]
@@ -494,6 +498,8 @@ class TestOverlay2Storage(DockerTestCase):
          '8ac48589692a53a9b8c2d1ceaa6b402665aa7fe667ba51ccc03002300856d8c7',
          'container_id':
          '8e8b7f23eb7cbd4dfe7e91646ddd0e0f524218e25d50113559f078dfb2690206',
+         'mount_id':
+         '92fd3b3e7d6101bb701743c9518c45b0d036b898c8a3d7cae84e1a06e6829b53',
          'start_date': '2018-05-16T10:51:39.625989',
          'image_name': 'busybox'}
     ]