[BUG] Compose won't find Dockerfile when in a symlinked folder
Description
Expected: Compose to build the image from the Dockerfile
Current:
[+] Building 0.0s (0/0) docker:desktop-linux
resolve : The system cannot find the path specified.
Steps To Reproduce
- Create a folder, then make a symlink pointing to that folder somewhere else. In my case the actual folder was on a separate drive, where the symlink was on the main drive.
- Create a Dockerfile. You don't to do specific tasks. We just need to get it to be valid. For what I know it might be a placeholder redirecting to another image.
- Create a Compose file. The name doesn't matters, I could reproduce the bug whenever it was named
compose.yamlordocker-compose.ymlfor example. Make sure it points to the Dockerfile using thebuild: .directive. - Go to the real directory and try the following commands:
docker build -t test .--> passdocker compose up -d --build--> pass
- Down the test compose project (optional, haven't tried without this step)
- Go to the symlinked directory and try the same commands:
docker build -t test .--> pass`docker compose up -d --build--> fail
Compose Version
Docker Compose version v2.35.1-desktop.1
Docker Environment
Client:
Version: 28.1.1
Context: desktop-linux
Debug Mode: false
Plugins:
ai: Docker AI Agent - Ask Gordon (Docker Inc.)
Version: v1.1.7
Path: C:\Program Files\Docker\cli-plugins\docker-ai.exe
buildx: Docker Buildx (Docker Inc.)
Version: v0.23.0-desktop.1
Path: C:\Program Files\Docker\cli-plugins\docker-buildx.exe
cloud: Docker Cloud (Docker Inc.)
Version: v0.3.0
Path: C:\Program Files\Docker\cli-plugins\docker-cloud.exe
compose: Docker Compose (Docker Inc.)
Version: v2.35.1-desktop.1
Path: C:\Program Files\Docker\cli-plugins\docker-compose.exe
debug: Get a shell into any image or container (Docker Inc.)
Version: 0.0.38
Path: C:\Program Files\Docker\cli-plugins\docker-debug.exe
desktop: Docker Desktop commands (Docker Inc.)
Version: v0.1.8
Path: C:\Program Files\Docker\cli-plugins\docker-desktop.exe
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.2
Path: C:\Program Files\Docker\cli-plugins\docker-dev.exe
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.27
Path: C:\Program Files\Docker\cli-plugins\docker-extension.exe
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v1.4.0
Path: C:\Program Files\Docker\cli-plugins\docker-init.exe
mcp: Docker MCP Plugin (Docker Inc.)
Version: dev
Path: C:\Program Files\Docker\cli-plugins\docker-mcp.exe
model: Docker Model Runner (Docker Inc.)
Version: v0.1.11
Path: C:\Program Files\Docker\cli-plugins\docker-model.exe
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: C:\Program Files\Docker\cli-plugins\docker-sbom.exe
scout: Docker Scout (Docker Inc.)
Version: v1.17.1
Path: C:\Program Files\Docker\cli-plugins\docker-scout.exe
Server:
Containers: 2
Running: 2
Paused: 0
Stopped: 0
Images: 2
Server Version: 28.1.1
Storage Driver: overlayfs
driver-type: io.containerd.snapshotter.v1
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
CDI spec directories:
/etc/cdi
/var/run/cdi
Swarm: inactive
Runtimes: io.containerd.runc.v2 nvidia runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 05044ec0a9a75232cad458027ca83437aae3f4da
runc version: v1.2.5-0-g59923ef
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
Kernel Version: 5.15.167.4-microsoft-standard-WSL2
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 12
Total Memory: 15.5GiB
Name: docker-desktop
ID: 0204b8f6-71e9-440a-9bb6-a5de617944c2
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Labels:
com.docker.desktop.address=npipe://\\.\pipe\docker_cli
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
::1/128
127.0.0.0/8
Live Restore Enabled: false
WARNING: No blkio throttle.read_bps_device support
WARNING: No blkio throttle.write_bps_device support
WARNING: No blkio throttle.read_iops_device support
WARNING: No blkio throttle.write_iops_device support
WARNING: DOCKER_INSECURE_NO_IPTABLES_RAW is set
WARNING: daemon is not using the default seccomp profile
Anything else?
Took me long enough to figure this out, and it surprised me that docker build worked, but not docker compose
Can't reproduce
$ ls -l test
total 32
-rw-r--r-- 1 nicolas staff 30 5 mai 08:34 compose.yaml
-rw-r--r-- 1 nicolas staff 12 29 avr 09:20 Dockerfile
$ ls -l link
lrwxr-xr-x 1 nicolas staff 4 5 mai 08:35 link -> test
$ cd link
$ docker compose up -d --build
...
=> [box] resolving provenance for metadata file 0.0s
[+] Running 3/3
✔ test Built
maybe specific to WSL when symlink points to a distinct windows drive ?
Can you please try running with COMPOSE_BAKE=true variable set ?
Hi @ndeloof this might indeed be a Windows only problem. With bake, it returns
=> [internal] load local bake definition 0.0s
failed to execute bake: exit status 1
However this issue happens also when in the real folder
Edit: formatting
However this issue happens also when in the real folder
Ouch. Unrelated to this issue then, but could you please run COMPOSE_BAKE=true docker compose --verbose build to capture the error and let me investigate ?
Sure thing @ndeloof. From the real folder:
time="2025-05-05T15:38:14+02:00" level=debug msg="Enabled Docker Desktop integration (experimental) @ npipe://\\\\.\\pipe\\docker_cli"
time="2025-05-05T15:38:14+02:00" level=debug msg="bake build config:\n{\n \"group\": {\n \"default\": {\n \"targets\": [\n \"alpine\"\n ]\n }\n },\n \"target\": {\n \"alpine\": {\n \"context\": \"D:\\\\dev\\\\test-docker\",\n \"dockerfile\": \"D:\\\\dev\\\\test-docker\\\\Dockerfile\",\n \"tags\": [\n \"test-docker-alpine\"\n ],\n \"output\": [\n \"type=docker,load=true,push=false\"\n ]\n }\n }\n}"
time="2025-05-05T15:38:14+02:00" level=debug msg="Executing bake with args: [bake --file - --progress rawjson --metadata-file C:\\Users\\Dev\\AppData\\Local\\Temp\\compose980585222 --allow fs.read=D:\\dev\\test-docker]"
time="2025-05-05T15:38:14+02:00" level=trace msg="Plugin server listening on @docker_cli_2b04244286d06b447f0e6543342508f7"
[+] Building 0.0s (1/1) FINISHED
=> [internal] load local bake definitions 0.1s
=> => reading from stdin 354B 0.1s
time="2025-05-05T15:38:14+02:00" level=debug msg="otel error" error="<nil>"
time="2025-05-05T15:38:14+02:00" level=debug msg="otel error" error="<nil>"
failed to evaluate path "D:\\dev\\test-docker/D:\\dev\\test-docker\\Dockerfile": CreateFile D:\dev\test-docker\D:: The filename, directory name, or volume label syntax is incorrect.
failed to evaluate path "D:\dev\test-docker/D:\dev\test-docker\Dockerfile
this is actually https://github.com/docker/compose/issues/12669, fixed by https://github.com/docker/buildx/pull/3141
this is actually fixed
Glad to hear! What about my initial issue tho?
Also dumping this log with COMPOSE_BAKE set to true, in the symlinked folder too.
time="2025-05-05T20:33:30+02:00" level=debug msg="Enabled Docker Desktop integration (experimental) @ npipe://\\\\.\\pipe\\docker_cli"
time="2025-05-05T20:33:30+02:00" level=debug msg="bake build config:\n{\n \"group\": {\n \"default\": {\n \"targets\": [\n \"alpine\"\n ]\n }\n },\n \"target\": {\n \"alpine\": {\n \"context\": \"C:\\\\Users\\\\Admin\\\\dev\\\\test-docker\",\n \"dockerfile\": \"C:\\\\Users\\\\Admin\\\\dev\\\\test-docker\\\\Dockerfile\",\n \"tags\": [\n \"test-docker-alpine\"\n ],\n \"output\": [\n \"type=docker,load=true,push=false\"\n ]\n }\n }\n}"
time="2025-05-05T20:33:30+02:00" level=debug msg="Executing bake with args: [bake --file - --progress rawjson --metadata-file C:\\Users\\Admin\\AppData\\Local\\Temp\\compose1458393954 --allow fs.read=C:\\Users\\Admin\\dev\\test-docker]"
time="2025-05-05T20:33:30+02:00" level=trace msg="Plugin server listening on @docker_cli_2d7e296de89e2638c729dbbe3503a2c4"
[+] Building 0.0s (1/1) FINISHED
=> [internal] load local bake definitions 0.1s
=> => reading from stdin 388B 0.1s
time="2025-05-05T20:33:30+02:00" level=debug msg="otel error" error="<nil>"
time="2025-05-05T20:33:30+02:00" level=debug msg="otel error" error="<nil>"
failed to evaluate path "C:\\Users\\Admin\\dev\\test-docker": The system cannot find the path specified.
is C:\Users\Admin\dev\test-docker the actual path to your build context or the symlink location ? Can you confirm docker build . is successful when ran from this folder ?
To be clear, C: is the symlink. docker build . indeed works from here.
I am also having this issue but with a junctioned* folder instead of a symlinked one.
The docker compose process works when done from the main/original folder but does not work with the junctioned* version.
I meant junctionned instead symlinked indeed
probably same cause as https://github.com/docker/compose/issues/12891
docker build . has some dedicated code to manage various corner cases that needs to be replicated
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Any update on this bug report?
This issue has been automatically marked as not stale anymore due to the recent activity.