From fbd1392a46558eb4adb368ba37fdce2b45013c1f Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Wed, 19 Sep 2018 09:54:15 -0400 Subject: Don't output inodes created to run a container There is a group of inodes that get created when running a container if they do not exist. containerMounts = map[string]bool{ "/dev": true, "/etc/hostname": true, "/etc/hosts": true, "/etc/resolv.conf": true, "/proc": true, "/run": true, "/run/.containerenv": true, "/run/secrets": true, "/sys": true, } If the destination inode does not exist, libpod/runc will create the inode. This can cause programs like podman diff to see the image as having changed, when actually it has not. This patch ignores changes in these inodes. Signed-off-by: Daniel J Walsh Closes: #1508 Approved by: giuseppe --- libpod/diff.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'libpod') diff --git a/libpod/diff.go b/libpod/diff.go index e86a186ed..f348e6b81 100644 --- a/libpod/diff.go +++ b/libpod/diff.go @@ -6,6 +6,18 @@ import ( "github.com/pkg/errors" ) +var containerMounts = map[string]bool{ + "/dev": true, + "/etc/hostname": true, + "/etc/hosts": true, + "/etc/resolv.conf": true, + "/proc": true, + "/run": true, + "/run/.containerenv": true, + "/run/secrets": true, + "/sys": true, +} + // GetDiff returns the differences between the two images, layers, or containers func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error) { toLayer, err := r.getLayerID(to) @@ -19,7 +31,17 @@ func (r *Runtime) GetDiff(from, to string) ([]archive.Change, error) { return nil, err } } - return r.store.Changes(fromLayer, toLayer) + var rchanges []archive.Change + changes, err := r.store.Changes(fromLayer, toLayer) + if err == nil { + for _, c := range changes { + if containerMounts[c.Path] { + continue + } + rchanges = append(rchanges, c) + } + } + return rchanges, err } // GetLayerID gets a full layer id given a full or partial id -- cgit v1.2.3-54-g00ecf