From 3342d4477c47e664ca2c6e7227b25efa65ec4496 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 11 Jan 2022 14:40:03 +0100 Subject: [PATCH] Docker: Switch Linux file handling to docker --exec by default Also on Linux, where there's actually a choice. It's slower, but less fragile when it comes to user ids and/or file system permissions. Change-Id: I811612fcff65fad50be18bed21150f6ca7fae93c Reviewed-by: Christian Stenger --- src/plugins/docker/dockerdevice.cpp | 9 +++++++++ src/plugins/docker/dockerdevice.h | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/docker/dockerdevice.cpp b/src/plugins/docker/dockerdevice.cpp index 1ff4627cfae..bc091fd5639 100644 --- a/src/plugins/docker/dockerdevice.cpp +++ b/src/plugins/docker/dockerdevice.cpp @@ -396,6 +396,13 @@ public: data.useLocalUidGid = on; }); + // This tries to find the directory in the host file system that corresponds to the + // docker container root file system, which is a merge of the layers from the + // container image and the volumes mapped using -v on container startup. + // + // Accessing files there is much faster than using 'docker exec', but conceptually + // only works on Linux, and is restricted there by proper matching of user + // permissions between host and container. m_usePathMapping = new QCheckBox(tr("Use local file path mapping")); m_usePathMapping->setToolTip(tr("Maps docker filesystem to a local directory.")); m_usePathMapping->setChecked(data.useFilePathMapping); @@ -960,8 +967,10 @@ void DockerDevicePrivate::tryCreateLocalFileAccess() } return; } + if (!DockerPlugin::isDaemonRunning().value_or(false)) return; + QtcProcess proc; proc.setCommand({"docker", {"inspect", "--format={{.GraphDriver.Data.MergedDir}}", m_container}}); LOG(proc.commandLine().toUserOutput()); diff --git a/src/plugins/docker/dockerdevice.h b/src/plugins/docker/dockerdevice.h index dea644ae24e..8bc837304ab 100644 --- a/src/plugins/docker/dockerdevice.h +++ b/src/plugins/docker/dockerdevice.h @@ -44,7 +44,7 @@ public: QString tag; QString size; bool useLocalUidGid = true; - bool useFilePathMapping = true; + bool useFilePathMapping = false; QStringList mounts; };