How to fix Error response from daemon: invalid mount config: mount path must be absolute in Docker

DockerBEGINNERLOWUpdated Dec 6, 2025ยท 333 views

This error occurs when you specify a relative path (like . or ./app) for a volume mount instead of an absolute path. Docker requires the full, complete path starting from the root directory for bind mounts to work correctly.

Quick fix

Fixes Error response from daemon: invalid mount config: mount path must be absolute

# Common problematic patterns:
docker run -v ./app:/app myimage          # Relative path with ./
docker run -v .:/code myimage             # Single dot
docker run -v ~/data:/data myimage        # Tilde for home
docker run -v data:/app myimage           # Missing leading slash
  1. Identify the problematic path in your command
  2. Convert relative paths to absolute paths
  3. Fix Git Bash path conversion issues on Windows
  4. Replace tilde (~) with full home path
docker โ€” error
# Common problematic patterns:
docker run -v ./app:/app myimage # Relative path with ./
docker run -v .:/code myimage # Single dot
docker run -v ~/data:/data myimage # Tilde for home
docker run -v data:/app myimage # Missing leading slash
Error response from daemon: invalid mount config: mount path must be absolute

What this error means

When Docker encounters "invalid mount config: mount path must be absolute," it means the path you provided for a volume or bind mount doesn't start from the filesystem root. Docker's volume mounting syntax requires absolute paths on both the host and container sides. An absolute path starts with a forward slash (`/`) on Linux/macOS or a drive letter like `C:\` on Windows. Relative paths like `.`, `./data`, or `../config` are not valid mount sources because Docker cannot reliably resolve them to a specific location. This error commonly occurs when: - Using `.` or `./` to refer to the current directory - Using `~` for the home directory (which some shells expand, but Docker doesn't) - Path conversion issues in Windows terminals (especially Git Bash/MinGW) - Copying commands from documentation that use relative paths as examples

Typical symptoms

  • Docker run command fails immediately with 'invalid mount config' error
  • docker-compose up fails with 'mount path must be absolute' message
  • Volume mounts work in PowerShell but fail in Git Bash on Windows
  • Commands copied from tutorials don't work on your system
  • Error mentions 'invalid volume destination path'
  • Mounts work on Linux but fail on Windows or macOS

Common causes

  1. Using relative paths like . or ./app instead of absolute paths
  2. Using tilde (~) for home directory which Docker doesn't expand
  3. Git Bash/MinGW on Windows converting Unix-style paths incorrectly
  4. Missing leading slash in the mount path specification
  5. Environment variable in path not being expanded properly
  6. Using $(pwd) without proper quoting in certain shells
  7. Path syntax mismatch between host OS and Docker's expectations

How to fix "Error response from daemon: invalid mount config: mount path must be absolute"

1Identify the problematic path in your command

First, locate the volume mount causing the error. Look for -v or --mount flags in your docker command, or volumes: in docker-compose.yml:

bash
# Common problematic patterns:
docker run -v ./app:/app myimage          # Relative path with ./
docker run -v .:/code myimage             # Single dot
docker run -v ~/data:/data myimage        # Tilde for home
docker run -v data:/app myimage           # Missing leading slash

The path before the colon (:) is the host path that must be absolute.

2Convert relative paths to absolute paths

Replace relative paths with full absolute paths. Use these methods to get the absolute path:

On Linux/macOS:

bash
# Get current directory as absolute path
pwd
# Example output: /home/user/project

# Use in docker command
docker run -v /home/user/project/app:/app myimage

# Or use command substitution
docker run -v "$(pwd)/app:/app" myimage

On Windows (PowerShell):

powershell
# Get current directory
Get-Location
# Example: C:\Users\user\project

# Use in docker command
docker run -v C:\Users\user\project\app:/app myimage

# Or use variable
docker run -v "${PWD}/app:/app" myimage
3Fix Git Bash path conversion issues on Windows

Git Bash (MinGW) automatically converts Unix-style paths to Windows paths, which can break Docker commands. Use one of these solutions:

Solution 1: Add extra leading slash

bash
# Instead of:
docker run -v $(pwd):/app myimage

# Use double leading slash:
docker run -v /$(pwd):/app myimage

# For explicit paths:
docker run -v //c/Users/user/project:/app myimage

Solution 2: Disable path conversion

bash
# Set environment variable for single command
MSYS_NO_PATHCONV=1 docker run -v $(pwd):/app myimage

# Or export for entire session
export MSYS_NO_PATHCONV=1
docker run -v $(pwd):/app myimage

Solution 3: Use Windows-native terminal
Run Docker commands from PowerShell or Command Prompt instead of Git Bash.

4Replace tilde (~) with full home path

Docker doesn't expand the tilde (~) character. Replace it with the actual home directory path:

On Linux/macOS:

bash
# Instead of:
docker run -v ~/data:/data myimage

# Use:
docker run -v /home/username/data:/data myimage

# Or use $HOME variable:
docker run -v "$HOME/data:/data" myimage

# Or use command substitution:
docker run -v "$(echo ~)/data:/data" myimage

On Windows:

powershell
# Instead of ~ use full path:
docker run -v C:\Users\username\data:/data myimage

# Or use environment variable:
docker run -v "$env:USERPROFILE\data:/data" myimage
5Fix docker-compose.yml volume paths

In docker-compose.yml, relative paths are resolved from the compose file's directory. However, you may still need absolute paths in some cases:

Using relative paths (usually works):

yaml
version: '3.8'
services:
  app:
    image: myimage
    volumes:
      - ./app:/app        # Relative to docker-compose.yml location
      - ./data:/data

If relative paths fail, use absolute:

yaml
version: '3.8'
services:
  app:
    image: myimage
    volumes:
      - /home/user/project/app:/app
      - /home/user/project/data:/data

Using environment variables:

yaml
services:
  app:
    volumes:
      - ${PWD}/app:/app
      - ${PROJECT_ROOT}/data:/data

Then run with:

bash
PROJECT_ROOT=/home/user/project docker-compose up
6Verify the path exists and is accessible

After fixing the path format, verify the directory exists:

bash
# Check if path exists
ls -la /home/user/project/app

# Create if needed
mkdir -p /home/user/project/app

# Test the mount
docker run --rm -v /home/user/project/app:/app alpine ls /app

If the directory doesn't exist, Docker will create it as root on Linux, which may cause permission issues later. It's better to create it beforehand with appropriate permissions.

7Use named volumes for simpler configuration

If you don't need to access files from the host, consider using named volumes instead of bind mounts. Named volumes don't require absolute paths:

bash
# Create a named volume
docker volume create mydata

# Use it in a container
docker run -v mydata:/app/data myimage

In docker-compose.yml:

yaml
version: '3.8'
services:
  app:
    image: myimage
    volumes:
      - mydata:/app/data

volumes:
  mydata:

Named volumes are managed by Docker and don't have path format issues across different operating systems.

Advanced notes

Understanding the path syntax:
The volume mount syntax is -v host_path:container_path[:options]. Both paths should be absolute:
- Host path: Where data lives on your machine (must be absolute)
- Container path: Where data appears inside the container (always absolute, Unix-style)

Windows path formats:
Windows supports multiple path formats with Docker:
- Native: C:\Users\user\data
- Forward slashes: C:/Users/user/data
- Unix-style (Docker Toolbox): /c/Users/user/data
- WSL paths: /mnt/c/Users/user/data

Docker Toolbox vs Docker Desktop:
Docker Toolbox (legacy) runs Docker in a VirtualBox VM, requiring paths to be shared through VirtualBox first. Docker Desktop on Windows uses WSL2 or Hyper-V and handles paths more seamlessly.

COMPOSE_CONVERT_WINDOWS_PATHS:
Set this environment variable to handle Windows paths in docker-compose:

bash
export COMPOSE_CONVERT_WINDOWS_PATHS=1
docker-compose up

CI/CD considerations:
In CI/CD pipelines, use environment variables or workspace paths provided by the CI system:

yaml
# GitHub Actions example
docker run -v ${{ github.workspace }}:/app myimage

Security note:
Mounting the current directory ($(pwd)) in development is convenient but avoid mounting sensitive directories in production. Use specific paths and consider read-only mounts (:ro) when the container doesn't need write access.

Frequently asked questions

What does "Error response from daemon: invalid mount config: mount path must be a" mean?
When Docker encounters "invalid mount config: mount path must be absolute," it means the path you provided for a volume or bind mount doesn't start from the filesystem root. Docker's volume mounting syntax requires absolute paths on both the host and container sides. An absolute path starts with a forward slash (/) on Linux/macOS or a drive letter like C:\ on Windows.
How do I fix "Error response from daemon: invalid mount config: mount path must be a"?
This error occurs when you specify a relative path (like . or ./app) for a volume mount instead of an absolute path. Docker requires the full, complete path starting from the root directory for bind mounts to work correctly.
What causes "Error response from daemon: invalid mount config: mount path must be a"?
Using relative paths like . or ./app instead of absolute paths Using tilde (~) for home directory which Docker doesn't expand Git Bash/MinGW on Windows converting Unix-style paths incorrectly
Is the "Error response from daemon: invalid mount config: mount path must be a" error serious?
It is a low-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading