A container will not start: mount path must be absolute
Invalid volume destination path: '.' mount path must be absoluteShort answer
The second half of a volume mapping is the path inside the container, and the daemon only accepts an absolute one. A dot, a bare folder name or a path starting with ./ on that side triggers this error. A mapping with only one path is also read as a container path. Put host path first, absolute container path second.
Fix it fast
1Find out which cause you have
Print the mounts Compose will actually pass on. The target of each one must start with a slash.
docker compose config | grep -B1 -A4 -E 'volumes:|target:'2Match what you see, then jump to its fix
- 1
invalid mount path: './data' (or '.', or 'data') mount path must be absoluteThe container side of the mapping is relativeFix - 2
The error names the very path you meant as the host folder, for example '.' or './data', and the entry has no colonOnly one path was written, so it became the container pathFix - 3
invalid mount path with a target: line in the file, not a short entryThe long syntax has a relative targetFix
- 1
What does the error look like?
Invalid volume destination path: '.' mount path must be absoluteinvalid mount path: '.' mount path must be absolute
Cause 1 of 3
The container side of the mapping is relative
1Check
A short volume entry reads HOST:CONTAINER. Relative paths are allowed on the host side, where they should start with . or .., but the destination inside the container is validated as an absolute path and cannot be the root path alone. Look for entries such as .:., ./db:db or ./app:./app.
grep -n -A6 'volumes:' docker-compose.yml compose.yaml 2>/dev/null2Fix
Keep the relative path on the left and give the container an absolute path on the right.
services:
app:
image: my-app:latest
volumes:
# wrong: - ./h2-data:h2-data
- ./h2-data:/opt/h2-data3Verify
The service starts and the folder is visible at the new path.
docker compose up -d
docker compose exec app ls /opt/h2-dataConfirmed by github.com
Cause 2 of 3
Only one path was written, so it became the container path
1Check
In -v and in the Compose short syntax the first field is optional. An entry with a single field has no source: it is taken as the destination inside the container and becomes an anonymous volume. Compose does not check that destination itself, so the engine rejects it. So - ./data is read as a container path, not a host one.
grep -n -A6 'volumes:' docker-compose.yml compose.yaml 2>/dev/null2Fix
Add the missing half. To share the current folder, write the folder, a colon, then the absolute path where it should appear.
services:
app:
image: my-app:latest
volumes:
# wrong: - .
- .:/app
# the same rule for docker run:
# docker run -v "$(pwd)":/app my-app:latest3Verify
Compose accepts the file, and the project files are listed inside the container.
docker compose config --quiet && echo OK
docker compose run --rm app ls /appConfirmed by docs.docker.com
Cause 3 of 3
The long syntax has a relative target
1Check
In docker run --mount, the destination must be an absolute path. The engine checks the target of every mount the same way, so in the long Compose form the source may be relative and the target may not.
grep -n -A4 'type: bind' docker-compose.yml compose.yaml 2>/dev/null2Fix
Keep source relative if you like, and make target absolute.
services:
app:
image: my-app:latest
volumes:
- type: bind
source: ./config
target: /etc/my-app3Verify
The file parses without the error.
docker compose config --quiet && echo OKConfirmed by docs.docker.com
How do I stop it coming back?
- Read every volumes line as HOST:CONTAINER and check that the part after the colon starts with a slash.
- Start every host path that is not a volume name with ./ or an absolute path, so it is never read as a name.
- Run docker compose config --quiet in CI to catch a bad mapping before a deploy.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
docker compose rejects a service that uses a volume nobody declared
Undefined volume with Docker Compose
A short volume entry like data:/var/lib/data names a volume called data.
3 causes, each with a fixServers
docker run or compose cannot mount a host folder that is not there
docker: Error response from daemon: invalid mount config for type "bind": bind source path does not exist: /dev/noexist
A bind mount needs a source folder on the host.
3 causes, each with a fixServers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fix