GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.86k stars 1.44k forks source link

bash not found after installation #2357

Open roquie opened 1 year ago

roquie commented 1 year ago

Actual behavior bash not installed but installed. Dockerfile example with this behavior:

FROM php:7.4-cli-alpine

RUN apk --no-cache add libzip-dev libpng-dev zip bash git \
    && apk --no-cache add --virtual .build-deps $PHPIZE_DEPS linux-headers \
    && docker-php-ext-install zip gd bcmath \
    && pecl install xdebug-2.9.1 \
    && docker-php-ext-enable xdebug \
    && apk del -f .build-deps

# BASH INSTALLED BUT NOT FOUND.... Kaniko magic. Image re-build with docker and pushed manually...
RUN bash --version

COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer

ENTRYPOINT [""]

after building image with kaniko executor (cache also purged) bash not found in the container. Log in to sh shell and type bash and got an not found error.

Expected behavior Installed bash. I re-build image with docker and after that I can log in to container using bash shell.

To Reproduce Steps to reproduce the behavior:

  1. build image with kaniko executor using dockerfile above
  2. view bash version in logs
  3. try to log in to this container after build using bash shell or sh shell (and then call bash manually)
  4. kaniko version 1.9.1

    Triage Notes for the Maintainers

    Description Yes/No
    Please check if this a new feature you are proposing
    • - [x]
    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
    • - [ ]
aaron-prindle commented 1 year ago

In attempting to reproduce this w/ the latest version of kaniko v1.10.0 I see that bash is installed in the kaniko created image:

Dockerfile

FROM php:7.4-cli-alpine

RUN apk --no-cache add libzip-dev libpng-dev zip bash git \
    && apk --no-cache add --virtual .build-deps $PHPIZE_DEPS linux-headers \
    && docker-php-ext-install zip gd bcmath \
    && pecl install xdebug-2.9.1 \
    && docker-php-ext-enable xdebug \
    && apk del -f .build-deps

# BASH INSTALLED BUT NOT FOUND.... Kaniko magic. Image re-build with docker and pushed manually...
RUN bash --version

COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer
aprindle@aprindle-ssd ~/kaniko  [main]./run_in_docker.sh /workspace/Dockerfile /usr/local/google/home/aprindle/kaniko-ctx-dir gcr.io/aprindle-test-cluster/kaniko-test:latest true
INFO[0000] Retrieving image manifest composer:1         
INFO[0000] Retrieving image composer:1 from registry index.docker.io 
INFO[0000] Storing source image from stage composer:1 at path /kaniko/stages/composer:1 
INFO[0005] Retrieving image manifest php:7.4-cli-alpine 
INFO[0005] Retrieving image php:7.4-cli-alpine from registry index.docker.io 
INFO[0006] Retrieving image manifest php:7.4-cli-alpine 
INFO[0006] Returning cached image manifest              
INFO[0006] Built cross stage deps: map[]                
INFO[0006] Retrieving image manifest php:7.4-cli-alpine 
INFO[0006] Returning cached image manifest              
INFO[0006] Retrieving image manifest php:7.4-cli-alpine 
INFO[0006] Returning cached image manifest              
INFO[0006] Executing 0 build triggers                   
INFO[0006] Building stage 'php:7.4-cli-alpine' [idx: '0', base-idx: '-1'] 
INFO[0006] Checking for cached layer gcr.io/aprindle-test-cluster/kaniko-test/cache:12ec07da48b554af49a8a239bfa3142d4e6406cd1280c8a6dac14cbc5d82eea4... 
INFO[0007] Using caching version of cmd: RUN apk --no-cache add libzip-dev libpng-dev zip bash git     && apk --no-cache add --virtual .build-deps $PHPIZE_DEPS linux-headers     && docker-php-ext-install zip gd bcmath     && pecl install xdebug-2.9.1     && docker-php-ext-enable xdebug     && apk del -f .build-deps 
INFO[0007] Checking for cached layer gcr.io/aprindle-test-cluster/kaniko-test/cache:19a54c00e5bdd5505c3c67dc104de30662ade9f1523c6f60942a31e38bc064e0... 
INFO[0007] Using caching version of cmd: RUN bash --version 
INFO[0007] Unpacking rootfs as cmd COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer requires it. 
INFO[0009] RUN apk --no-cache add libzip-dev libpng-dev zip bash git     && apk --no-cache add --virtual .build-deps $PHPIZE_DEPS linux-headers     && docker-php-ext-install zip gd bcmath     && pecl install xdebug-2.9.1     && docker-php-ext-enable xdebug     && apk del -f .build-deps 
INFO[0009] Found cached layer, extracting to filesystem 
INFO[0009] RUN bash --version                           
INFO[0009] Found cached layer, extracting to filesystem 
INFO[0009] COPY --from=composer:1 /usr/bin/composer /usr/local/bin/composer 
INFO[0009] Taking snapshot of files...                  
INFO[0009] ENTRYPOINT [""]                              
INFO[0009] No files changed in this command, skipping snapshotting. 
INFO[0009] Pushing image to gcr.io/aprindle-test-cluster/kaniko-test:latest 
INFO[0013] Pushed gcr.io/aprindle-test-cluster/kaniko-test@sha256:80fbc60607bb743c0fe3af251559c62ec29cfba5de432ea321a864920182637a 
aprindle@aprindle-ssd ~/kaniko  [main]docker pull gcr.io/aprindle-test-cluster/kaniko-test:latest
latest: Pulling from aprindle-test-cluster/kaniko-test
ca7dd9ec2225: Already exists 
1b78b4fe0ca1: Already exists 
9d6040f2a28f: Already exists 
0e2e66b89284: Already exists 
3b1be5f02bec: Already exists 
96243f515dda: Already exists 
4006f78ca99d: Already exists 
3c76b37a5dd7: Already exists 
6491a80416fc: Already exists 
29ec5b8b7d93: Already exists 
89732bc75041: Pull complete 
9a680892638d: Pull complete 
Digest: sha256:80fbc60607bb743c0fe3af251559c62ec29cfba5de432ea321a864920182637a
Status: Downloaded newer image for gcr.io/aprindle-test-cluster/kaniko-test:latest
gcr.io/aprindle-test-cluster/kaniko-test:latest
aprindle@aprindle-ssd ~/kaniko  [main]docker run -it --entrypoint=/bin/bash gcr.io/aprindle-test-cluster/kaniko-test:latest
bash-5.1# which bash
/bin/bash
bash-5.1# bash
bash-5.1# 

Are you still encountering this issue? Do you have any tips on the exact steps you are using to reproduce this? Thanks