Merge pull request #20 from thaJeztah/18.06-backport-do_not_Healthcheck_RUN_command

[18.06] Ensure RUN instruction to run without Healthcheck
diff --git a/api/server/router/build/build_routes.go b/api/server/router/build/build_routes.go
index c4699f3..3073479 100644
--- a/api/server/router/build/build_routes.go
+++ b/api/server/router/build/build_routes.go
@@ -208,7 +208,6 @@
 			output.Write(notVerboseBuffer.Bytes())
 		}
 
-		logrus.Debugf("isflushed %v", output.Flushed())
 		// Do not write the error in the http output if it's still empty.
 		// This prevents from writing a 200(OK) when there is an internal error.
 		if !output.Flushed() {
diff --git a/builder/builder-next/adapters/snapshot/snapshot.go b/builder/builder-next/adapters/snapshot/snapshot.go
index 9934c8a..5b2c583 100644
--- a/builder/builder-next/adapters/snapshot/snapshot.go
+++ b/builder/builder-next/adapters/snapshot/snapshot.go
@@ -245,21 +245,23 @@
 	}
 	if l != nil {
 		id := identity.NewID()
-		rwlayer, err := s.opt.LayerStore.CreateRWLayer(id, l.ChainID(), nil)
-		if err != nil {
-			return nil, err
-		}
-		rootfs, err := rwlayer.Mount("")
-		if err != nil {
-			return nil, err
-		}
-		mnt := []mount.Mount{{
-			Source:  rootfs.Path(),
-			Type:    "bind",
-			Options: []string{"rbind"},
-		}}
-		return &constMountable{
-			mounts: mnt,
+		var rwlayer layer.RWLayer
+		return &mountable{
+			acquire: func() ([]mount.Mount, error) {
+				rwlayer, err = s.opt.LayerStore.CreateRWLayer(id, l.ChainID(), nil)
+				if err != nil {
+					return nil, err
+				}
+				rootfs, err := rwlayer.Mount("")
+				if err != nil {
+					return nil, err
+				}
+				return []mount.Mount{{
+					Source:  rootfs.Path(),
+					Type:    "bind",
+					Options: []string{"rbind"},
+				}}, nil
+			},
 			release: func() error {
 				_, err := s.opt.LayerStore.ReleaseRWLayer(rwlayer)
 				return err
@@ -269,17 +271,18 @@
 
 	id, _ := s.getGraphDriverID(key)
 
-	rootfs, err := s.opt.GraphDriver.Get(id, "")
-	if err != nil {
-		return nil, err
-	}
-	mnt := []mount.Mount{{
-		Source:  rootfs.Path(),
-		Type:    "bind",
-		Options: []string{"rbind"},
-	}}
-	return &constMountable{
-		mounts: mnt,
+	return &mountable{
+		acquire: func() ([]mount.Mount, error) {
+			rootfs, err := s.opt.GraphDriver.Get(id, "")
+			if err != nil {
+				return nil, err
+			}
+			return []mount.Mount{{
+				Source:  rootfs.Path(),
+				Type:    "bind",
+				Options: []string{"rbind"},
+			}}, nil
+		},
 		release: func() error {
 			return s.opt.GraphDriver.Put(id)
 		},
@@ -428,18 +431,37 @@
 	return s.db.Close()
 }
 
-type constMountable struct {
+type mountable struct {
+	mu      sync.Mutex
 	mounts  []mount.Mount
+	acquire func() ([]mount.Mount, error)
 	release func() error
 }
 
-func (m *constMountable) Mount() ([]mount.Mount, error) {
+func (m *mountable) Mount() ([]mount.Mount, error) {
+	m.mu.Lock()
+	defer m.mu.Unlock()
+
+	if m.mounts != nil {
+		return m.mounts, nil
+	}
+
+	mounts, err := m.acquire()
+	if err != nil {
+		return nil, err
+	}
+	m.mounts = mounts
+
 	return m.mounts, nil
 }
 
-func (m *constMountable) Release() error {
+func (m *mountable) Release() error {
+	m.mu.Lock()
+	defer m.mu.Unlock()
 	if m.release == nil {
 		return nil
 	}
+
+	m.mounts = nil
 	return m.release()
 }
diff --git a/vendor.conf b/vendor.conf
index fc6388e..024bbbf 100644
--- a/vendor.conf
+++ b/vendor.conf
@@ -37,7 +37,7 @@
 #get libnetwork packages
 
 # When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy accordingly
-github.com/docker/libnetwork 3ac297bc7fd0afec9051bbb47024c9bc1d75bf5b
+github.com/docker/libnetwork d00ceed44cc447c77f25cdf5d59e83163bdcb4c9
 github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
 github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
diff --git a/vendor/github.com/docker/libnetwork/osl/namespace_linux.go b/vendor/github.com/docker/libnetwork/osl/namespace_linux.go
index 996a250..45c4685 100644
--- a/vendor/github.com/docker/libnetwork/osl/namespace_linux.go
+++ b/vendor/github.com/docker/libnetwork/osl/namespace_linux.go
@@ -616,6 +616,15 @@
 		value = byte('0')
 	}
 
+	if _, err := os.Stat(path); err != nil {
+		if os.IsNotExist(err) {
+			logrus.Warnf("file does not exist: %s : %v Has IPv6 been disabled in this node's kernel?", path, err)
+			os.Exit(0)
+		}
+		logrus.Errorf("failed to stat %s : %v", path, err)
+		os.Exit(5)
+	}
+
 	if err = ioutil.WriteFile(path, []byte{value, '\n'}, 0644); err != nil {
 		logrus.Errorf("failed to %s IPv6 forwarding for container's interface %s: %v", action, os.Args[2], err)
 		os.Exit(4)
diff --git a/vendor/github.com/docker/libnetwork/vendor.conf b/vendor/github.com/docker/libnetwork/vendor.conf
index f0beb1e..0a99a43 100644
--- a/vendor/github.com/docker/libnetwork/vendor.conf
+++ b/vendor/github.com/docker/libnetwork/vendor.conf
@@ -6,12 +6,9 @@
 github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
 github.com/boltdb/bolt fff57c100f4dea1905678da7e90d92429dff2904
 github.com/codegangsta/cli a65b733b303f0055f8d324d805f393cd3e7a7904
-github.com/containerd/console cb7008ab3d8359b78c5f464cb7cf160107ad5925
 github.com/containerd/continuity d3c23511c1bf5851696cba83143d9cbcd666869b
 github.com/coreos/etcd v3.2.1
 github.com/coreos/go-semver v0.2.0
-github.com/coreos/go-systemd v17
-github.com/coreos/pkg fa29b1d70f0beaddd4c7021607cc3c3be8ce94b8
 github.com/deckarep/golang-set ef32fa3046d9f249d399f98ebaf9be944430fd1d
 
 github.com/docker/docker 162ba6016def672690ee4a1f3978368853a1e149
@@ -22,7 +19,6 @@
 
 github.com/godbus/dbus v4.0.0
 github.com/gogo/protobuf v1.0.0
-github.com/golang/protobuf v1.1.0
 github.com/gorilla/context v1.1
 github.com/gorilla/mux v1.1
 github.com/hashicorp/consul v0.5.2
@@ -34,16 +30,12 @@
 github.com/hashicorp/serf 598c54895cc5a7b1a24a398d635e8c0ea0959870
 github.com/mattn/go-shellwords v1.0.3
 github.com/miekg/dns v1.0.7
-github.com/mrunalp/fileutils ed869b029674c0e9ce4c0dfa781405c2d9946d08
 github.com/opencontainers/go-digest v1.0.0-rc1
 github.com/opencontainers/image-spec v1.0.1
 github.com/opencontainers/runc 69663f0bd4b60df09991c08812a60108003fa340
 github.com/opencontainers/runtime-spec v1.0.1
-github.com/opencontainers/selinux b29023b86e4a69d1b46b7e7b4e2b6fda03f0b9cd
 github.com/samuel/go-zookeeper d0e0d8e11f318e000a8cc434616d69e329edc374
-github.com/seccomp/libseccomp-golang 32f571b70023028bd57d9288c20efbcb237f3ce0
 github.com/sirupsen/logrus v1.0.3
-github.com/stretchr/testify v1.2.2
 github.com/syndtr/gocapability 33e07d32887e1e06b7c025f27ce52f62c7990bc0
 github.com/ugorji/go f1f1a805ed361a0e078bb537e4ea78cd37dcf065
 github.com/vishvananda/netlink b2de5d10e38ecce8607e6b438b6d174f389a004e
@@ -55,12 +47,5 @@
 github.com/pkg/errors 839d9e913e063e28dfd0e6c7b7512793e0a48be9
 github.com/ishidawataru/sctp 07191f837fedd2f13d1ec7b5f885f0f3ec54b1cb
 
-github.com/davecgh/go-spew v1.1.0
-github.com/pmezard/go-difflib v1.0.0
-github.com/cyphar/filepath-securejoin v0.2.1
-github.com/hashicorp/errwrap 7554cd9344cec97297fa6649b055a8c98c2a1e55
-github.com/hashicorp/go-immutable-radix 7f3cd4390caab3250a57f30efdb2a65dd7649ecf
-github.com/hashicorp/golang-lru 0fb14efe8c47ae851c0034ed7a448854d3d34cf3
-github.com/hashicorp/go-cleanhttp d5fe4b57a186c716b0e00b8c301cbd9b4182694d
-github.com/hashicorp/go-rootcerts 6bb64b370b90e7ef1fa532be9e591a81c3493e00
-github.com/mitchellh/go-homedir 3864e76763d94a6df2f9960b16a20a33da9f9a66
+gotest.tools v2.1.0
+github.com/google/go-cmp v0.2.0