{"record":{"id":"3cf94793c78c902c","repo":"testcontainers/testcontainers-java","slug":"unable-to-mount-a-file-from-test-host-into-a-running","errorCode":null,"errorMessage":"Unable to mount a file from test host into a running container. This may be a misconfiguration or limitation of your Docker environment. Some features might not work.","messagePattern":"Unable to mount a file from test host into a running container\\. This may be a misconfiguration or limitation of your Docker environment\\. Some features might not work\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/testcontainers/containers/ContainerDef.java","lineNumber":118,"sourceCode":"\n        if (this.command != null) {\n            createCommand.withCmd(this.command);\n        }\n\n        if (this.network != null) {\n            hostConfig.withNetworkMode(this.network.getId());\n            createCommand.withAliases(this.networkAliases.toArray(new String[0]));\n        } else {\n            if (this.networkMode != null) {\n                createCommand.getHostConfig().withNetworkMode(this.networkMode);\n            }\n        }\n\n        boolean shouldCheckFileMountingSupport =\n            this.binds.size() > 0 && !TestcontainersConfiguration.getInstance().isDisableChecks();\n        if (shouldCheckFileMountingSupport) {\n            if (!DockerClientFactory.instance().isFileMountingSupported()) {\n                log.warn(\n                    \"Unable to mount a file from test host into a running container. \" +\n                    \"This may be a misconfiguration or limitation of your Docker environment. \" +\n                    \"Some features might not work.\"\n                );\n            }\n        }\n\n        hostConfig.withBinds(this.binds.toArray(new Bind[0]));\n\n        if (this.privilegedMode) {\n            createCommand.getHostConfig().withPrivileged(this.privilegedMode);\n        }\n\n        Map<String, String> combinedLabels = new HashMap<>(this.labels);\n        if (createCommand.getLabels() != null) {\n            combinedLabels.putAll(createCommand.getLabels());\n        }\n","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/containers/ContainerDef.java#L100-L136","documentation":"ContainerDef.applyTo() checks whether the Docker environment supports host file binds when the container definition has binds configured. If DockerClientFactory reports file mounting is unsupported (common in some remote/rootless setups), a WARN is emitted; container creation proceeds but bind-mounted features may silently not work.","triggerScenarios":"Container definition contains bind mounts (copyToFileContainerPathMap/binds non-empty), checks are not disabled, and DockerClientFactory.instance().isFileMountingSupported() returns false — e.g. Docker inaccessible mount probing failed.","commonSituations":"Remote Docker daemons (DOCKER_HOST over TCP/ssh) where the daemon cannot see host paths; rootless Docker or podman setups; Windows/macOS VM-based Docker with misconfigured shared folders.","solutions":["Ensure the Docker daemon runs locally or that paths exist identically on the daemon host","Verify shared-folder configuration for Docker Desktop / remote daemons","Disable the check via TestcontainersConfiguration isDisableChecks only if you know mounts work","Replace bind mounts with container copies (withCopyFileToContainer) if mounting is genuinely unsupported"],"exampleFix":"// before\ncontainer.withFileSystemBind(\"./config\", \"/etc/config\", READ_WRITE);\n// after\ncontainer.withCopyFileToContainer(MountableFile.forHostPath(\"./config\"), \"/etc/config\");","handlingStrategy":"validation","validationCode":"// Probe mount support before relying on binds\nboolean mountsOk = DockerClientFactory.instance().isFileMountingSupported();\nif (!mountsOk) {\n    // fall back to copy-based file transfer instead of bind mounts\n    container.withCopyFileToContainer(MountableFile.forHostPath(\"./conf\"), \"/etc/conf\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check isFileMountingSupported() before configuring binds","Prefer withCopyFileToContainer for config files on remote daemons","Keep the Docker daemon local or configure shared folders properly"],"tags":["bind-mount","docker","environment","non-fatal"],"backgroundTag":"file-mounting-unsupported","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}