Open Akkyma232 opened 7 months ago
This is an expected behavior, the relative path is relative to the dockerfile itself. Only the root dockerfile is relative to the build context. From the documentation:
The paths resolutions for imported Dockerfiles from the root Dockerfile are relative to the docker build context, not the root Dockerfile itself. This is due to a limitation in BuildKit and this is consistent with other instructions that are also relative the context.
However, the paths resolutions for imported Dockerfiles from the imported Dockerfiles are relative to the imported Dockerfile itself.
If you really need to use the build context in the include path, we could think as a kind of variable or something like FROM $BUILD_CONTEXT/dockerfiles/Dockerfile.stage2
Hi!
Thank you for this project. I have problems when I try to separate my build to several stages using Relative FROM. It seems like that this feature cause relative path corruption when there are more than one Relative FROM in dockerfiles chain
How to reproduce
Project structure:
Dockerfile.stage1:
Dockerfile.stage2:
Dockerfile.stage3:
Execute:
When I run stage1 and stage2 builds it works fine:
docker build -f dockerfiles/Dockerfile.stage1 .
docker build -f dockerfiles/Dockerfile.stage2 .
But stage3 build exits with error:
docker build -f dockerfiles/Dockerfile.stage3 .
Output:
Problem
Seems like first Relative FROM in chain change cwd for next Relative FROMs
Expected behaviour:
Relative FROM always works relative to build context