#2764·kaniko

Kaniko deletes all content inside `$HOME` directory when using multiple `FROM` elements inside `Dockerfile`.

Author: GamePlayer-8Created Sep 28, 2023Updated Jun 2, 2025
Labelskind/bugarea/multi-stage buildspriority/p0area/filesystemsneeds-discussionworks-with-dockerdiffers-from-dockerissue/missing-files

Actual behavior When I'm using multiple FROM <image name> inside Dockerfile kaniko somehow deletes everything inside $HOME directory (at least when running on root). Causing the push option of the image to error since the credentials are stored in $HOME/.docker.

Expected behavior Kaniko should build an image with multiple FROM <image name> elements just fine, without deleting content inside $HOME and pushing the image without any problem.

To Reproduce Steps to reproduce the behavior:

  1. Install kaniko inside i.e. alpine container.
  2. Install docker
  3. Create credentials file with docker login
  4. Create an example Dockerfile outside of $HOME directory:
dockerfile
FROM alpine AS builder

RUN echo "First image."

FROM alpine

COPY --from=builder /bin/sh .

RUN echo "Second image."

CMD ["/bin/sh"]
  1. Build a Docker image and try to push it onto the specified docker registry (from docker login). Use command kaniko --context . --dockerfile ./Dockerfile --destination your.registry/username/package
  2. kaniko should crash and after doing ls -a $HOME the directory should be shown as empty.
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
  • - [X]
Please check if this error is seen when you use --cache flag
  • - [X]
Please check if your dockerfile is a multistage dockerfile
  • - [X]

Source: GoogleContainerTools/kaniko