Skip to content

[BUG] Compose won't find Dockerfile when in a symlinked folder #12799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GeekCornerGH opened this issue May 3, 2025 · 11 comments
Open

[BUG] Compose won't find Dockerfile when in a symlinked folder #12799

GeekCornerGH opened this issue May 3, 2025 · 11 comments
Labels

Comments

@GeekCornerGH
Copy link

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

  1. 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.
  2. 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.
  3. Create a Compose file. The name doesn't matters, I could reproduce the bug whenever it was named compose.yaml or docker-compose.yml for example. Make sure it points to the Dockerfile using the build: . directive.
  4. Go to the real directory and try the following commands:
    • docker build -t test . --> pass
    • docker compose up -d --build --> pass
  5. Down the test compose project (optional, haven't tried without this step)
  6. 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

@ndeloof
Copy link
Contributor

ndeloof commented May 5, 2025

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   

@ndeloof
Copy link
Contributor

ndeloof commented May 5, 2025

maybe specific to WSL when symlink points to a distinct windows drive ?

@ndeloof
Copy link
Contributor

ndeloof commented May 5, 2025

Can you please try running with COMPOSE_BAKE=true variable set ?

@GeekCornerGH
Copy link
Author

GeekCornerGH commented May 5, 2025

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

@ndeloof
Copy link
Contributor

ndeloof commented May 5, 2025

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 ?

@GeekCornerGH
Copy link
Author

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.

@ndeloof
Copy link
Contributor

ndeloof commented May 5, 2025

failed to evaluate path "D:\dev\test-docker/D:\dev\test-docker\Dockerfile

this is actually #12669, fixed by docker/buildx#3141

@GeekCornerGH
Copy link
Author

GeekCornerGH commented May 5, 2025

this is actually fixed

Glad to hear! What about my initial issue tho?

@GeekCornerGH
Copy link
Author

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.

@ndeloof
Copy link
Contributor

ndeloof commented May 6, 2025

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 ?

@GeekCornerGH
Copy link
Author

To be clear, C: is the symlink. docker build . indeed works from here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants