{"record":{"id":"ca327ce30c15135e","repo":"cross-rs/cross","slug":"remote-and-docker-in-docker-are-unlikely-to-work-together","errorCode":null,"errorMessage":"remote and docker-in-docker are unlikely to work together when using cross. remote cross uses data volumes, so docker-in-docker should not be required.","messagePattern":"remote and docker-in-docker are unlikely to work together when using cross\\. remote cross uses data volumes, so docker-in-docker should not be required\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/docker/remote.rs","lineNumber":758,"sourceCode":"    }\n}\n\npub(crate) fn run(\n    options: DockerOptions,\n    paths: DockerPaths,\n    args: &[String],\n    subcommand: Option<crate::Subcommand>,\n    msg_info: &mut MessageInfo,\n) -> Result<Option<ExitStatus>> {\n    let engine = &options.engine;\n    let target = &options.target;\n    let toolchain_dirs = paths.directories.toolchain_directories();\n    let package_dirs = paths.directories.package_directories();\n\n    let mount_prefix = MOUNT_PREFIX;\n\n    if options.in_docker() {\n        msg_info.warn(\"remote and docker-in-docker are unlikely to work together when using cross. remote cross uses data volumes, so docker-in-docker should not be required.\")?;\n    }\n\n    // the logic is broken into the following steps\n    // 1. get our unique identifiers and cleanup from a previous run.\n    // 2. if not using persistent volumes, create a data volume\n    // 3. start our container with the mounted data volume and all envvars\n    // 4. copy data into the data volume\n    //      with persistent data volumes, copy just copy crate data and\n    //      if not present, the toolchain for the current target.\n    //      otherwise, copy the entire toolchain, cargo, and crate data\n    //      if `CROSS_REMOTE_COPY_CACHE`, copy over the target dir as well\n    // 5. create symlinks for all mounted data\n    //      ensure the paths are the same as local cross\n    // 6. execute our cargo command inside the container\n    // 7. copy data from target dir back to host\n    // 8. stop container and delete data volume\n    //\n    // we use structs that wrap the resources to ensure they're dropped","sourceCodeStart":740,"sourceCodeEnd":776,"githubUrl":"https://github.com/cross-rs/cross/blob/8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27/src/docker/remote.rs#L740-L776","documentation":"cross's remote mode manages data volumes itself, so running it inside docker-in-docker (nested Docker) is unnecessary and typically breaks volume sharing. When run() detects in_docker(), it warns that the combination is unlikely to work.","triggerScenarios":"Calling run() for a remote build while in_docker() is true — i.e. the engine reports the cross container is itself running inside a Docker container (CROSS_CONTAINER_IN_CONTAINER set or detected).","commonSituations":"CI jobs that run cross inside a container with a Docker socket mounted and remote/cluster mode enabled; developers testing remote builds from a devcontainer.","solutions":["Run cross directly on the host (or outside the nested container) when using remote mode.","Disable docker-in-docker by unsetting CROSS_CONTAINER_IN_CONTAINER / CROSS_DOCKER_IN_DOCKER.","If nesting is unavoidable, mount the needed volumes explicitly through both Docker layers so the data volume is shared."],"exampleFix":"# before (inside container)\nexport CROSS_CONTAINER_IN_CONTAINER=1\ncross build --remote --target aarch64-unknown-linux-gnu\n\n# after (on host)\nunset CROSS_CONTAINER_IN_CONTAINER\ncross build --remote --target aarch64-unknown-linux-gnu","handlingStrategy":"validation","validationCode":"# Guard remote usage against nested docker\nif [ -n \"${CROSS_CONTAINER_IN_CONTAINER:-}\" ] || [ -n \"${CROSS_DOCKER_IN_DOCKER:-}\" ]; then\n  echo \"remote mode unsupported under docker-in-docker\"; exit 1\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run remote builds from the host, not inside devcontainers","Don't combine --remote with docker-in-docker CI templates","Set CROSS_CONTAINER_IN_CONTAINER only for local (non-remote) containerized runs"],"tags":["docker","remote","docker-in-docker","environment"],"backgroundTag":"conflicting-config-options","analyzedSha":"8c1a8aa4b661711f4b7b6ac07c2e8929ce2f7d27","analyzedAt":"2026-09-13T15:10:43.988Z","contentChangedAt":"2026-09-13T15:10:43.988Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}