---
# SPDX-License-Identifier: CC-BY-SA-4.0
# SPDX-FileCopyrightText: Netresearch DTT GmbH
name: docker-via-wsl
description: "Use when YOU (the AI agent) are running on Windows OUTSIDE WSL (Git Bash/MSYS/PowerShell shell) and need to run ANY docker / docker compose command. Docker Desktop runs on the WSL2 engine, so commands must be re-issued INSIDE WSL via wsl.exe -- running them from the Windows shell on a network/SMB drive (Z:, UNC) corrupts bind-mount paths. Does NOT apply if your shell is already inside WSL. Triggers on: docker, docker compose, docker-compose, container, bind mount, volume, 'is a directory', mount source wrong, Windows + Docker Desktop, WSL."
license: "(MIT AND CC-BY-SA-4.0)"
compatibility: "Windows host with Docker Desktop using the WSL2 backend."
metadata:
  version: "1.21.0"
  repository: "https://github.com/netresearch/docker-development-skill"
  author: "Netresearch DTT GmbH"
allowed-tools:
  - "Bash(docker version:*)"
  - "Bash(docker info:*)"
  - "Bash(docker ps:*)"
  - "Bash(docker inspect:*)"
  - "Bash(uname:*)"
  - "Read"
  - "Glob"
  - "Grep"
title: docker-via-wsl
canonical_url: https://skilld.dev/gh/netresearch/docker-development-skill/docker-via-wsl
last_updated: 2026-11-21T19:17:21.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/diagnosis-and-fix.md](https://skilld.dev/api/skills-raw/netresearch/docker-development-skill/docker-via-wsl/references/diagnosis-and-fix.md).
>
> If the user asked to install this Skill, run `npx skilld install netresearch/docker-development-skill/docker-via-wsl`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/docker-via-wsl`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/netresearch/docker-development-skill/docker-via-wsl) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/docker-via-wsl`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/docker-via-wsl --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/docker-via-wsl --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Docker via WSL (Windows)

## When this applies

This applies when **you, the AI agent, are running on a Windows host and your
shell is OUTSIDE WSL** -- your Bash tool is Git Bash/MSYS (`uname -s` shows
`MINGW64…`/`MSYS…`) or you are in PowerShell/cmd. The `docker` binary there
talks to Docker Desktop, but the daemon and its filesystem live in WSL2, so you
must run commands inside WSL via `wsl.exe`.

If your shell is **already inside WSL** (`uname -s` shows `Linux`, native path
`/home/<user>/...`), this skill does **not** apply -- run `docker` directly.

## The problem

On Windows, Docker Desktop's daemon runs **inside the WSL2 VM**. Issue **every
`docker` command** -- `run`, `build`, `exec`, `pull`, `push`,
`volume`, `network`, `inspect`, `compose`, … -- **from inside WSL**, against a
**native Linux path**. Never from a Windows shell (Git Bash/MSYS/PowerShell),
especially on a mapped network/SMB drive (`Z:`, UNC `\\host\share`).

## Why it matters

Driving Docker from a Windows shell whose CWD is on a network share forces
Docker Desktop to translate the Windows bind path (e.g. `Z:\proj\config`) into
a VM path. On SMB/UNC drives this is unreliable: it can **duplicate a path
segment** (e.g. `…/user/user/proj/config`), so Docker mounts a **wrong, empty
directory** and **auto-creates the missing bind source as an empty directory**.
A file the container expects (`init.sql`, a config file) then appears as a
**directory** -> `could not read from input file: Is a directory`. Your editor
writes still land on the *correct* path via the share, so host and container
views silently diverge.

This is NOT a Docker cache bug nor a "single-file bind mounts are fragile"
problem (single-file binds work fine from WSL). The root cause is **piloting
Docker from Windows/SMB instead of from WSL**.

## The rule

Run **any** Docker command through WSL, in a native Linux path:

```bash
wsl.exe -e bash -lc "cd /home/<user>/<project> && docker compose up -d"
wsl.exe -e bash -lc "docker ps"
wsl.exe -e bash -lc "docker build -t myimg /home/<user>/<project>"
```

Keep the project on the **Linux filesystem** the WSL distro sees natively
(`/home/<user>/...`), not browsed through the Windows drive letter.

## Diagnosis and fix

See `references/diagnosis-and-fix.md` for inspecting the mounted path, comparing
host vs container views, and cleaning up a phantom bind directory.
