{"record":{"id":"cb053ab9938af4f0","repo":"testcontainers/testcontainers-java","slug":"a-large-amount-of-data-was-sent-to-the-docker-daemon","errorCode":null,"errorMessage":"A large amount of data was sent to the Docker daemon ({}). Consider using a .dockerignore file for better performance.","messagePattern":"A large amount of data was sent to the Docker daemon \\((.+?)\\)\\. Consider using a \\.dockerignore file for better performance\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/testcontainers/images/builder/ImageFromDockerfile.java","lineNumber":159,"sourceCode":"            long bytesToDockerDaemon = 0;\n\n            // To build an image, we have to send the context to Docker in TAR archive format\n            try (TarArchiveOutputStream tarArchive = new TarArchiveOutputStream(new GZIPOutputStream(out))) {\n                tarArchive.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);\n                tarArchive.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);\n\n                for (Map.Entry<String, Transferable> entry : transferables.entrySet()) {\n                    Transferable transferable = entry.getValue();\n                    final String destination = entry.getKey();\n                    transferable.transferTo(tarArchive, destination);\n                    bytesToDockerDaemon += transferable.getSize();\n                }\n                tarArchive.finish();\n            }\n\n            log.info(\"Transferred {} to Docker daemon\", FileUtils.byteCountToDisplaySize(bytesToDockerDaemon));\n            if (bytesToDockerDaemon > FileUtils.ONE_MB * 50) {\n                log.warn( // warn if >50MB sent to docker daemon\n                    \"A large amount of data was sent to the Docker daemon ({}). Consider using a .dockerignore file for better performance.\",\n                    FileUtils.byteCountToDisplaySize(bytesToDockerDaemon)\n                );\n            }\n\n            exec.awaitImageId();\n\n            return dockerImageName;\n        } catch (IOException e) {\n            throw new RuntimeException(\"Can't close DockerClient\", e);\n        }\n    }\n\n    protected void configure(BuildImageCmd buildImageCmd) {\n        buildImageCmd.withTags(Collections.singleton(getDockerImageName()));\n        this.dockerFilePath.ifPresent(buildImageCmd::withDockerfilePath);\n        this.dockerfile.ifPresent(p -> {\n                buildImageCmd.withDockerfile(p.toFile());","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/core/src/main/java/org/testcontainers/images/builder/ImageFromDockerfile.java#L141-L177","documentation":"When ImageFromDockerfile streams the build context tarball to the Docker daemon, it counts bytes and warns when more than 50MB is transferred. Large contexts slow builds dramatically; the common cause is accidentally including build artifacts, node_modules, or big data files because there is no .dockerignore.","triggerScenarios":"ImageFromDockerfile.resolve() (via imageId) finishes transferring the tar archive and bytesToDockerDaemon > 50MB.","commonSituations":"withFileFromDirectory pointing at a project root without a .dockerignore; copying target/, node_modules/, .git, or datasets into the build context; Dockerfile-based images built in CI from large monorepo directories.","solutions":["Add a .dockerignore (or use withFileFromString/.dockerignore support) to exclude build outputs, .git, and deps","Build context from a minimal directory containing only files the Dockerfile COPYs","Copy individual files with withFileFromString/withFileFromClasspath instead of whole directories"],"exampleFix":"// before\nnew ImageFromDockerfile().withFileFromPath(\".\", projectRoot)\n// after: dockerignore excluding junk\nnew ImageFromDockerfile()\n    .withFileFromString(\".dockerignore\", \"target\\nnode_modules\\n.git\\n*.log\")\n    .withFileFromPath(\".\", projectRoot);","handlingStrategy":"validation","validationCode":"long size = Files.walk(contextDir).mapToLong(p -> p.toFile().length()).sum();\nif (size > 50L * 1024 * 1024) {\n    throw new IllegalStateException(\"Build context too large: \" + size + \" bytes — add .dockerignore\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always ship a .dockerignore in build contexts","Copy only needed files, not whole directories","Check context size in CI before building"],"tags":["testcontainers","docker-build","performance","dockerignore"],"backgroundTag":"payload-too-large","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"}