From d591710f82a20e6f84038d5dbc67282fd50ea6bc Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Tue, 8 Feb 2022 23:14:23 +0100 Subject: [PATCH 1/2] Handle docker start inside overlayfs Raspberry Pi allows to start system under overlayfs. Docker is successfully fallbacks to fuse-overlay but not starting because of the `Error starting daemon: rename /var/lib/docker/runtimes /var/lib/docker/runtimes-old: invalid cross-device link` error It's happening because `rename` is not supported by overlayfs. After manually removing directory `runtimes` docker starts and works successfully Signed-off-by: Illia Antypenko --- daemon/runtime_unix.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/runtime_unix.go b/daemon/runtime_unix.go index 52e976f75f..12e7048b6c 100644 --- a/daemon/runtime_unix.go +++ b/daemon/runtime_unix.go @@ -69,7 +69,9 @@ func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error } if err = os.Rename(runtimeDir, runtimeDir+"-old"); err != nil { - return + if err = os.RemoveAll(runtimeDir); err != nil { + return + } } if err = os.Rename(tmpDir, runtimeDir); err != nil { err = errors.Wrap(err, "failed to setup runtimes dir, new containers may not start") From 07ba3e35d3e1936bd175351c575c21491ccbb6ed Mon Sep 17 00:00:00 2001 From: Illia Antypenko Date: Fri, 18 Nov 2022 09:05:42 +0100 Subject: [PATCH 2/2] Add additional loggig in case of error of renaming runtimes-old and removing it Signed-off-by: Illia Antypenko --- daemon/runtime_unix.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/daemon/runtime_unix.go b/daemon/runtime_unix.go index 12e7048b6c..b7ef4ae853 100644 --- a/daemon/runtime_unix.go +++ b/daemon/runtime_unix.go @@ -53,8 +53,9 @@ func (daemon *Daemon) loadRuntimes() error { func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error) { runtimeDir := filepath.Join(daemon.configStore.Root, "runtimes") + runtimeOldDir := runtimeDir + "-old" // Remove old temp directory if any - os.RemoveAll(runtimeDir + "-old") + os.RemoveAll(runtimeOldDir) tmpDir, err := os.MkdirTemp(daemon.configStore.Root, "gen-runtimes") if err != nil { return errors.Wrap(err, "failed to get temp dir to generate runtime scripts") @@ -68,8 +69,12 @@ func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error return } - if err = os.Rename(runtimeDir, runtimeDir+"-old"); err != nil { + if err = os.Rename(runtimeDir, runtimeOldDir); err != nil { + logrus.WithError(err).WithField("dir", runtimeDir). + Warn("failed to rename runtimes dir to old. Will try to removing it") if err = os.RemoveAll(runtimeDir); err != nil { + logrus.WithError(err).WithField("dir", runtimeDir). + Warn("failed to remove old runtimes dir") return } } @@ -77,8 +82,8 @@ func (daemon *Daemon) initRuntimes(runtimes map[string]types.Runtime) (err error err = errors.Wrap(err, "failed to setup runtimes dir, new containers may not start") return } - if err = os.RemoveAll(runtimeDir + "-old"); err != nil { - logrus.WithError(err).WithField("dir", tmpDir). + if err = os.RemoveAll(runtimeOldDir); err != nil { + logrus.WithError(err).WithField("dir", runtimeOldDir). Warn("failed to remove old runtimes dir") } }()