Skip to content
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

error building image: error building stage: failed to get filesystem from image: mkdir /usr/share/file/magic: not a directory #1469

Closed
Anugushashank opened this issue Oct 28, 2020 · 6 comments · Fixed by #1478

Comments

@Anugushashank
Copy link
Contributor

Anugushashank commented Oct 28, 2020

Actual behavior
When kaniko executor is run as a binary from another image, it fails with error
error building image: error building stage: failed to get filesystem from image: mkdir /usr/share/file/magic: not a directory

This issue occurs only when there is a difference in filesystem of container image and the base image of the dockerfile. Ex: /usr/share/file/magic is a directory in the base image whereas it a file in container filesystem.

Why is this happening:
While building a stage, FS is extracted in each layer from tar and gets created on the container except for the mounted directories. While extracting the FS, if there is a dir(/usr/share/file/magic) which needs to be created on the container, and there is already a file(/usr/share/file/magic) with same path on the container then an error(not a directory) is thrown

Expected behavior
Kaniko executor should not fail while creating a dir if there is already a file with the same path.

There should be a check here, if there exists a file with the dir path then it should be deleted before proceeding with the dir creation

To Reproduce
Steps to reproduce the behavior:

  1. Build this dockerfile using docker and tag it as container_image, docker build -t container_image .
FROM gcr.io/kaniko-project/executor:debug as kanikoImage

FROM amazoncorretto:11

COPY --from=kanikoImage /kaniko/executor /kaniko/executor
  1. Build below docker file using kaniko executor from above created image, docker run -v {dockerfile_location}:/workspace container_image /kaniko/executor --dockerfile /workspace/Dockerfile --no-push --verbosity=trace
FROM python:3.7.6

RUN apt-get update && \
    apt-get install -y virtualenv git default-mysql-client
  1. Above build fails with error error building image: error building stage: failed to get filesystem from image: mkdir /usr/share/file/magic: not a directory

Additional Information

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
Anugushashank pushed a commit to Anugushashank/kaniko that referenced this issue Nov 3, 2020
Anugushashank added a commit to Anugushashank/kaniko that referenced this issue Nov 4, 2020
Anugushashank added a commit to Anugushashank/kaniko that referenced this issue Nov 4, 2020
Anugushashank added a commit to Anugushashank/kaniko that referenced this issue Nov 4, 2020
Anugushashank added a commit to Anugushashank/kaniko that referenced this issue Nov 5, 2020
Anugushashank pushed a commit to Anugushashank/kaniko that referenced this issue Nov 5, 2020
Anugushashank pushed a commit to Anugushashank/kaniko that referenced this issue Nov 5, 2020
tejal29 pushed a commit that referenced this issue Nov 5, 2020
* Fixes #1469 : Remove file that matches with the directory path

* Fixes #1469 : Remove file that matches with the directory path

* Fixes #1469 : Fix lint errors

* Fixes #1469 : Fix lint errors

* Fixes #1469 : Fix lint errors

* Fixes #1469 : Reduce conditional depth

* Fixes #1469 : Remove an additional line

Co-authored-by: anugu-chegg <anugu.s@chegg.com>
@defaultcute12
Copy link

Hi, is this issue fixed?

@anugu-chegg
Copy link
Contributor

@vl-shopback
Copy link

we got the same issue on Kaniko version : v1.8.1 + amazoncorretto:17

@gulldan
Copy link

gulldan commented Mar 29, 2023

we got the same issue on Kaniko version : v1.9.2 + nvcr.io/nvidia/deepstream:6.2-devel

@sherman-yang
Copy link

get the same issue with Kaniko:v1.9.1

@Aishwarya-Lad
Copy link

Has this been fixed? I am getting the same issue with Kaniko:v1.8.0.

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

Successfully merging a pull request may close this issue.

7 participants