*/docker: fix bind mount bug

Fix issue where bind mounts do not start for docker 18.05.0. Backports
moby/moby commit 379845ec20ae651831dcfb0587b95c38a1631a53.
This commit is contained in:
Andrew Jeddeloh 2018-05-24 11:42:36 -07:00
parent 5ab818467c
commit 526c3e04ae
4 changed files with 70 additions and 2 deletions

View File

@ -74,7 +74,9 @@ RESTRICT="installsources strip"
S="${WORKDIR}/${P}/src/${COREOS_GO_PACKAGE}"
ENGINE_PATCHES=()
ENGINE_PATCHES=(
"${FILESDIR}/fix-bind-mount-bug2440.patch"
)
# see "contrib/check-config.sh" from upstream's sources
CONFIG_CHECK="

View File

@ -0,0 +1,66 @@
From d8fd6137a1f6d95a2bcdfeb6e1dfa6b816790c5e Mon Sep 17 00:00:00 2001
From: Kir Kolyshkin <kolyshkin@gmail.com>
Date: Thu, 10 May 2018 12:01:50 -0700
Subject: [PATCH] daemon.getSourceMount(): fix for / mount point
A recent optimization in getSourceMount() made it return an error
in case when the found mount point is "/". This prevented bind-mounted
volumes from working in such cases.
A (rather trivial but adeqate) unit test case is added.
Fixes: 871c957242 ("getSourceMount(): simplify")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
---
daemon/oci_linux.go | 8 +-------
daemon/oci_linux_test.go | 14 ++++++++++++++
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/daemon/oci_linux.go b/daemon/oci_linux.go
index 62e7c7f1d682..766701a41683 100644
--- a/daemon/oci_linux.go
+++ b/daemon/oci_linux.go
@@ -405,13 +405,7 @@ func getSourceMount(source string) (string, string, error) {
idx = i
}
}
- // and return it unless it's "/"
- if mi[idx].Mountpoint != "/" {
- return mi[idx].Mountpoint, mi[idx].Optional, nil
- }
-
- // If we are here, we did not find parent mount. Something is wrong.
- return "", "", fmt.Errorf("Could not find source mount of %s", source)
+ return mi[idx].Mountpoint, mi[idx].Optional, nil
}
const (
diff --git a/daemon/oci_linux_test.go b/daemon/oci_linux_test.go
index 5f2731b8d652..e28fac004efd 100644
--- a/daemon/oci_linux_test.go
+++ b/daemon/oci_linux_test.go
@@ -1,6 +1,7 @@
package daemon // import "github.com/docker/docker/daemon"
import (
+ "os"
"testing"
containertypes "github.com/docker/docker/api/types/container"
@@ -86,3 +87,16 @@ func TestIpcPrivateVsReadonly(t *testing.T) {
assert.Check(t, is.Equal(false, inSlice(m.Options, "ro")))
}
}
+
+func TestGetSourceMount(t *testing.T) {
+ // must be able to find source mount for /
+ mnt, _, err := getSourceMount("/")
+ assert.NilError(t, err)
+ assert.Equal(t, mnt, "/")
+
+ // must be able to find source mount for current directory
+ cwd, err := os.Getwd()
+ assert.NilError(t, err)
+ _, _, err = getSourceMount(cwd)
+ assert.NilError(t, err)
+}

View File

@ -11,7 +11,7 @@ KEYWORDS="amd64 arm64"
# Explicitly list all packages that will be built into the image.
RDEPEND="
=app-emulation/docker-18.05.0
=app-emulation/docker-18.05.0-r1
=app-emulation/containerd-1.0.3
=app-emulation/docker-proxy-0.8.0_p20180411
=app-emulation/docker-runc-1.0.0_rc5