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

Kaniko remove file copied from an other image if a link (sym or hard) is created on this or a file copied in folder #2314

Open
emeric-martineau opened this issue Nov 8, 2022 · 1 comment
Labels
area/filesystems For all bugs related to kaniko container filesystems (mounting issues etc) area/multi-stage builds issues related to kaniko multi-stage builds area/symlinks categorized cmd/copy differs-from-docker issue/missing-files kind/bug Something isn't working priority/p0 Highest priority. Break user flow. We are actively looking at delivering it. priority/p1 Basic need feature compatibility with docker build. we should be working on this next. works-with-docker

Comments

@emeric-martineau
Copy link

emeric-martineau commented Nov 8, 2022

Actual behavior
When we copy file from another image:

COPY --from=kaniko /kaniko/executor /kaniko/executor

and create a link (sym or hard) on this:

RUN  ln -s /kaniko/executor /usr/local/bin/kaniko

the folder /kaniko is removed.

Same behavior if create a file in /kaniko folder:

RUN touch /kaniko/empty

Expected behavior
Buildkit compatibility. With buildkit link exists and /kaniko/ is keep.

To Reproduce
Create a image with this Dockerfile:

FROM gcr.io/kaniko-project/executor:v1.9.1 as kaniko

FROM ubuntu:22.04 as target

ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

# Initial required packages
RUN \
  apt-get update && \
  apt-get install -y --no-install-recommends \
    ca-certificates \
    apt-utils \
    bash \
    curl \
    unzip \
    git \
    tzdata \
    gettext-base 

COPY --from=kaniko /kaniko/executor /kaniko/executor
COPY --from=kaniko /kaniko/docker-credential-gcr /kaniko/docker-credential-gcr
COPY --from=kaniko /kaniko/docker-credential-ecr-login /kaniko/docker-credential-ecr-login
COPY --from=kaniko /kaniko/docker-credential-acr-env /kaniko/docker-credential-acr-env
COPY --from=kaniko /kaniko/ssl/certs/ /kaniko/ssl/certs/
COPY --from=kaniko /kaniko/.docker /kaniko/.docker
COPY --from=kaniko /etc/nsswitch.conf /etc/nsswitch.conf

ENV SSL_CERT_DIR=/kaniko/ssl/certs
ENV DOCKER_CONFIG /kaniko/.docker/
ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json

RUN  ln -s /kaniko/executor /usr/local/bin/kaniko

Error happend when we use docker image gcr.io/kaniko-project/executor:v1.9.1

Additional Information
Workaround:

FROM gcr.io/kaniko-project/executor:v1.9.1 as kaniko

FROM ubuntu:22.04 as target

ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

COPY --from=kaniko /kaniko/executor /kaniko/executor
COPY --from=kaniko /kaniko/docker-credential-gcr /kaniko/docker-credential-gcr
COPY --from=kaniko /kaniko/docker-credential-ecr-login /kaniko/docker-credential-ecr-login
COPY --from=kaniko /kaniko/docker-credential-acr-env /kaniko/docker-credential-acr-env
COPY --from=kaniko /kaniko/ssl/certs/ /kaniko/ssl/certs/
COPY --from=kaniko /kaniko/.docker /kaniko/.docker
COPY --from=kaniko /etc/nsswitch.conf /etc/nsswitch.conf

ENV SSL_CERT_DIR=/kaniko/ssl/certs
ENV DOCKER_CONFIG /kaniko/.docker/
ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json

#--------------------------------------------------------------------------------------------------
# Just move here, now, it's working 
#--------------------------------------------------------------------------------------------------
# Initial required packages
RUN \
  apt-get update && \
  apt-get install -y --no-install-recommends \
    ca-certificates \
    apt-utils \
    bash \
    curl \
    unzip \
    git \
    tzdata \
    gettext-base 

RUN  ln -s /kaniko/executor /usr/local/bin/kaniko

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing no
Please check if the build works in docker but not in kaniko yes
Please check if this error is seen when you use --cache flag yes
Please check if your dockerfile is a multistage dockerfile yes
@emeric-martineau
Copy link
Author

emeric-martineau commented Nov 9, 2022

I found another case:

FROM gcr.io/kaniko-project/executor:v1.9.1 as kaniko

FROM ubuntu:22.04 as target

ENV TERM xterm
ENV DEBIAN_FRONTEND noninteractive

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN mkdir -p /kaniko/

COPY --from=kaniko /kaniko/executor /kaniko/executor
COPY --from=kaniko /kaniko/docker-credential-gcr /kaniko/docker-credential-gcr
COPY --from=kaniko /kaniko/docker-credential-ecr-login /kaniko/docker-credential-ecr-login
COPY --from=kaniko /kaniko/docker-credential-acr-env /kaniko/docker-credential-acr-env
COPY --from=kaniko /kaniko/ssl/certs/ /kaniko/ssl/certs/
COPY --from=kaniko /kaniko/.docker /kaniko/.docker
COPY --from=kaniko /etc/nsswitch.conf /etc/nsswitch.conf

ENV SSL_CERT_DIR=/kaniko/ssl/certs
ENV DOCKER_CONFIG /kaniko/.docker/
ENV DOCKER_CREDENTIAL_GCR_CONFIG /kaniko/.config/gcloud/docker_credential_gcr_config.json

RUN echo "ddd" > /toto

if I remove RUN mkdir -p /kaniko/ I don't have issue.

No issue if I use Docker to build

@aaron-prindle aaron-prindle added kind/bug Something isn't working area/filesystems For all bugs related to kaniko container filesystems (mounting issues etc) cmd/copy issue/missing-files works-with-docker differs-from-docker area/symlinks priority/p0 Highest priority. Break user flow. We are actively looking at delivering it. priority/p1 Basic need feature compatibility with docker build. we should be working on this next. area/multi-stage builds issues related to kaniko multi-stage builds categorized labels Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/filesystems For all bugs related to kaniko container filesystems (mounting issues etc) area/multi-stage builds issues related to kaniko multi-stage builds area/symlinks categorized cmd/copy differs-from-docker issue/missing-files kind/bug Something isn't working priority/p0 Highest priority. Break user flow. We are actively looking at delivering it. priority/p1 Basic need feature compatibility with docker build. we should be working on this next. works-with-docker
Projects
None yet
Development

No branches or pull requests

2 participants