Skip to content

[BUG] Dockerfile.dockeringore is ignored if Dockerfile is a link #13014

@luciangabor

Description

@luciangabor

Description

Using multiple dockerfiles with a twist - symbolic links instead of more files - stopped working recently

Steps To Reproduce

create a Dockerfile with the following content:

FROM alpine
RUN --mount=target=/mnt/ ls -lA /mnt/

create a compose.yaml with the following content:

services:
  service:
    build:
      dockerfile: link

create the link symlink ln -s Dockerfile link and a link.dockeringore with the following content:

*

Then run docker compose --progress=plain build --no-cache and observe the output:

#7 [stage-0 2/2] RUN --mount=target=/mnt/ ls -lA /mnt/
#7 0.137 total 16
#7 0.137 -rw-r--r--    1 root     root            50 Jul  3 14:36 Dockerfile
#7 0.137 -rw-r--r--    1 root     root            56 Jul  3 14:43 compose.yaml
#7 0.137 lrwxrwxrwx    1 root     root            10 Jul  3 14:50 link -> Dockerfile
#7 0.137 -rw-r--r--    1 root     root             2 Jul  3 14:59 link.dockerignore
#7 DONE 0.2s

Compare this with docker bake --progress=plain --no-cache or docker buildx build --progress=plain --no-cache -f link .:

#5 [stage-0 2/2] RUN --mount=target=/mnt/ ls -lA /mnt/
#5 0.138 total 0
#5 DONE 0.2s

Compose Version

Docker Compose version v2.38.1

Docker Environment


Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions