How to fix Error response from daemon: invalid mount config: bind source path does not exist in Docker

DockerBEGINNERMEDIUMUpdated Dec 1, 2025· 384 views

This error occurs when Docker cannot find the host directory or file you're trying to bind mount into a container. The source path must exist on the host before using the --mount flag.

Quick fix

Fixes Error response from daemon: invalid mount config: bind source path does not exist

# Check if path exists (Linux/macOS)
ls -la /path/to/your/directory

# On Windows (PowerShell)
Test-Path "C:\path\to\your\directory"

# Check the exact error message for the path Docker is looking for
docker run --mount type=bind,source=/path/to/mount,target=/app myimage 2>&1
  1. Verify the source path exists on your host
  2. Create the missing directory
  3. Use -v flag instead of --mount for auto-creation
  4. Fix tilde and environment variable expansion
docker — error
# Check if path exists (Linux/macOS)
ls -la /path/to/your/directory
# On Windows (PowerShell)
Test-Path "C:\path\to\your\directory"
# Check the exact error message for the path Docker is looking for
docker run --mount type=bind,source=/path/to/mount,target=/app myimage 2>&1
Error response from daemon: invalid mount config: bind source path does not exist

What this error means

When Docker reports "invalid mount config: bind source path does not exist," it means the directory or file you specified as the source for a bind mount doesn't exist on your host system. Unlike the `-v` flag which can auto-create missing directories, the `--mount` flag with `type=bind` requires the source path to exist beforehand. This is a deliberate design choice to prevent accidental directory creation and make mount configurations more explicit. This error commonly occurs when: - The path was misspelled or uses incorrect case sensitivity - The directory hasn't been created yet - You're referencing a path that exists on another machine (like in Docker Swarm) - The path format doesn't match your operating system's expectations - Environment variables in the path weren't expanded properly

Typical symptoms

  • Docker run command fails with 'invalid mount config for type bind' error
  • docker-compose up fails stating bind source path does not exist
  • Container starts on some machines but fails on others in a Swarm cluster
  • Commands that worked before suddenly fail after system changes
  • Error shows a path that looks correct but Docker can't find it
  • CI/CD pipeline fails at container start with mount errors

Common causes

  1. The source directory or file does not exist on the host filesystem
  2. Using --mount flag which requires pre-existing paths (unlike -v)
  3. Path typo or incorrect case sensitivity (especially on Linux)
  4. In Docker Swarm, the path doesn't exist on all nodes
  5. Tilde (~) not being expanded to the home directory
  6. Environment variables not being expanded in the path
  7. Docker Desktop file sharing not configured for the parent directory
  8. Path refers to a location inside a container rather than the host
  9. Windows path format incompatible with Docker's expectations

How to fix "Error response from daemon: invalid mount config: bind source path does not exist"

1Verify the source path exists on your host

First, check if the directory or file you're trying to mount actually exists:

bash
# Check if path exists (Linux/macOS)
ls -la /path/to/your/directory

# On Windows (PowerShell)
Test-Path "C:\path\to\your\directory"

# Check the exact error message for the path Docker is looking for
docker run --mount type=bind,source=/path/to/mount,target=/app myimage 2>&1

If the path doesn't exist, you'll see "No such file or directory" or similar output.

2Create the missing directory

If the directory doesn't exist, create it before running your Docker command:

bash
# Create directory on Linux/macOS
mkdir -p /path/to/your/directory

# Create directory on Windows (PowerShell)
New-Item -ItemType Directory -Path "C:\path\to\your\directory" -Force

# Verify it was created
ls -la /path/to/your/directory

The -p flag creates parent directories as needed and doesn't error if the directory already exists.

3Use -v flag instead of --mount for auto-creation

If you want Docker to automatically create the directory when it doesn't exist, use the -v flag instead of --mount:

bash
# --mount flag (requires path to exist)
docker run --mount type=bind,source=/data/app,target=/app myimage
# Error: bind source path does not exist

# -v flag (creates directory if missing)
docker run -v /data/app:/app myimage
# Works! Creates /data/app as root-owned directory

Note: Directories created by -v will be owned by root, which may cause permission issues later. It's usually better to create directories beforehand with proper ownership.

4Fix tilde and environment variable expansion

Docker doesn't expand ~ or environment variables in paths. Use full paths or shell expansion:

bash
# This won't work - tilde not expanded
docker run --mount type=bind,source=~/data,target=/data myimage

# Solution 1: Use full path
docker run --mount type=bind,source=/home/username/data,target=/data myimage

# Solution 2: Use $HOME variable (shell expands it)
docker run --mount type=bind,source="$HOME/data",target=/data myimage

# Solution 3: Use command substitution
docker run --mount type=bind,source="$(echo ~)/data",target=/data myimage

# For environment variables, ensure they're expanded by the shell
export MY_DATA_PATH=/data/app
docker run --mount type=bind,source="$MY_DATA_PATH",target=/app myimage
5Configure Docker Desktop file sharing (macOS/Windows)

On macOS and Windows, Docker Desktop must have access to the directories you want to mount:

Docker Desktop for Mac:
1. Click the Docker icon in menu bar
2. Go to Preferences > Resources > File Sharing
3. Add the parent directory of your mount path
4. Click "Apply & Restart"

Docker Desktop for Windows:
1. Right-click Docker icon in system tray
2. Select Settings > Resources > File Sharing
3. Add the drive or directory you want to share
4. Click "Apply & Restart"

bash
# Common paths that need sharing:
# macOS: /Users, /Volumes, /private, /tmp
# Windows: C:\Users, D:\ (or other drives)

# After adding file sharing, retry your command
docker run --mount type=bind,source=/Users/me/project,target=/app myimage
6Fix paths for Docker Swarm deployments

In Docker Swarm mode, bind mount paths must exist on every node where the service might run:

bash
# Check which nodes will run your service
docker node ls

# Create the directory on ALL Swarm nodes
# SSH to each node and run:
ssh node1 "mkdir -p /data/app"
ssh node2 "mkdir -p /data/app"
ssh node3 "mkdir -p /data/app"

# Or use a constraint to run only on specific nodes
docker service create \
  --constraint 'node.hostname==node1' \
  --mount type=bind,source=/data/app,target=/app \
  myimage

Alternative for Swarm: Use Docker volumes instead of bind mounts - they're replicated across nodes:

bash
docker volume create --driver local mydata
docker service create --mount source=mydata,target=/app myimage
7Fix Windows path format issues

Windows paths need special handling depending on your terminal:

PowerShell:

powershell
# Use Windows-style paths
docker run --mount type=bind,source=C:\Users\me\data,target=/app myimage

# Or with forward slashes
docker run --mount type=bind,source=C:/Users/me/data,target=/app myimage

Git Bash (MinGW):

bash
# Use Unix-style path with leading //
docker run --mount type=bind,source=//c/Users/me/data,target=/app myimage

# Or disable path conversion
MSYS_NO_PATHCONV=1 docker run --mount type=bind,source=/c/Users/me/data,target=/app myimage

WSL2:

bash
# Windows paths are mounted under /mnt
docker run --mount type=bind,source=/mnt/c/Users/me/data,target=/app myimage

# For WSL filesystem paths
docker run --mount type=bind,source=/home/me/data,target=/app myimage
8Use docker-compose with automatic path creation

Docker Compose v2.35.0+ requires explicit configuration to create missing directories. Use the bind.create_host_path option:

yaml
version: '3.8'
services:
  app:
    image: myimage
    volumes:
      - type: bind
        source: ./data
        target: /app/data
        bind:
          create_host_path: true  # Creates directory if missing

For older compose files using short syntax, the behavior depends on your Docker Compose version:

yaml
version: '3.8'
services:
  app:
    image: myimage
    volumes:
      - ./data:/app/data  # May auto-create in older versions

If you're getting this error with docker-compose, check your version:

bash
docker compose version
# or
docker-compose --version

Advanced notes

Behavior differences between -v and --mount:
The --mount flag was introduced to be more explicit and safer than -v. Key differences:
- --mount fails if source doesn't exist (intentional safety feature)
- -v creates the source directory if missing (owned by root)
- --mount syntax is more verbose but clearer about what's happening

Docker-in-Docker (DinD) considerations:
When running Docker inside Docker, bind mounts reference the outer host's filesystem, not the container's:

bash
# Inside a DinD container, this path must exist on the HOST
docker run -v /data:/data myimage
# /data refers to the original host, not the DinD container

SELinux and bind mounts:
On SELinux-enabled systems (RHEL, CentOS, Fedora), you may need to add the :z or :Z suffix:

bash
docker run --mount type=bind,source=/data,target=/app,bind-propagation=rslave \
  -v /data:/app:z myimage

Read-only bind mounts:
If the container only needs to read files, use read-only mounts to prevent accidental modifications:

bash
docker run --mount type=bind,source=/config,target=/app/config,readonly myimage
# or
docker run -v /config:/app/config:ro myimage

Debugging file sharing issues:

bash
# List Docker's available mounts
docker info | grep -i "root dir"

# Check Docker's file sharing configuration
docker info | grep -i "file sharing"

# Test with a simple Alpine container
docker run --rm -it --mount type=bind,source=/your/path,target=/test alpine ls /test

Frequently asked questions

What does "Error response from daemon: invalid mount config: bind source path doe" mean?
When Docker reports "invalid mount config: bind source path does not exist," it means the directory or file you specified as the source for a bind mount doesn't exist on your host system. Unlike the -v flag which can auto-create missing directories, the --mount flag with type=bind requires the source path to exist beforehand. This is a deliberate design choice to prevent accidental directory creation and make mount configurations more explicit.
How do I fix "Error response from daemon: invalid mount config: bind source path doe"?
This error occurs when Docker cannot find the host directory or file you're trying to bind mount into a container. The source path must exist on the host before using the --mount flag.
What causes "Error response from daemon: invalid mount config: bind source path doe"?
The source directory or file does not exist on the host filesystem Using --mount flag which requires pre-existing paths (unlike -v) Path typo or incorrect case sensitivity (especially on Linux)
Is the "Error response from daemon: invalid mount config: bind source path doe" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading