skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

build can not use dockerfiles out of the docker context

Open jairov4 opened this issue 2 years ago • 1 comments

skaffold build will complain with:

Error response from daemon: forbidden path outside the build context: ../platform/microservice/python3.9-poetry-microservice.dockerfile (). Docker build ran into internal error. Please retry.
If this keeps happening, please open an issue..

Expected behavior

Skaffold should be able to map the configuration to docker build my-app/ -f platform/microservice/python3.9-poetry-microservice.dockerfile (even not sure why skaffold is using dockerfile path relative to the context, the documentation says that it is relative to the workspace)

Actual behavior

Skaffold is failing complaining with an error message indicating the dockerfile is out of the docker context. But docker has not that limitation.

Information

  • Skaffold version: v1.38.0
  • Operating system: Centos 8
  • Installed via: curl https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2beta11
kind: Config
build:
  artifacts:
    - image: my-app
      context: my-app
      docker:
        dockerfile: ../platform/microservice/python3.9-poetry-microservice.dockerfile

Steps to reproduce the behavior

  1. create skaffold.yaml as provided, create the my-app folder
  2. skaffold build

logs:

 - my-app: Not found. Building
INFO[0001] Cache check completed in 1.916 second         subtask=-1 task=Build
Starting build...
Building [my-app]...
DEBU[0001] Running docker build: context: my-app, dockerfile: ../platform/microservice/python3.9-poetry-microservice.dockerfile  subtask=my-app task=Build
DEBU[0001] Skipping credential configuration because docker-credential-gcloud is not on PATH.  subtask=-1 task=DevLoop
Sending build context to Docker daemon  66.72MB
DEBU[0002] Running command: [tput colors]                subtask=-1 task=DevLoop
DEBU[0002] Command output: [256
]                        subtask=-1 task=DevLoop
Error response from daemon: forbidden path outside the build context: ../platform/microservice/python3.9-poetry-microservice.dockerfile (). Docker build ran into internal error. Please retry.
If this keeps happening, please open an issue..

jairov4 avatar Jun 05 '22 01:06 jairov4

Unfortunately that is the design decision we took. Normally dockerfiles are kept closer to the code. Is there a reason why you have yours in a different directory?

tejal29 avatar Sep 12 '22 18:09 tejal29