GoogleContainerTools / kaniko

Build Container Images In Kubernetes
Apache License 2.0
14.52k stars 1.42k forks source link

Cannot install bash with Alpine 3.12 #1335

Open chrw opened 4 years ago

chrw commented 4 years ago

Actual behavior

I have the following Dockerfile in place.

FROM alpine:3.12
RUN apk add --no-cache bash

I create the container using Kaniko in the current version (v0.23.0) within Gitlab CI using the Docke executor with the official kaniko container image.

$ executor --context ${PWD} --dockerfile ${PWD}/Dockerfile --destination bashtest:latest
INFO[0000] Retrieving image manifest alpine:3.12        
INFO[0001] Retrieving image manifest alpine:3.12        
INFO[0002] Built cross stage deps: map[]                
INFO[0002] Retrieving image manifest alpine:3.12        
INFO[0004] Retrieving image manifest alpine:3.12        
INFO[0005] Executing 0 build triggers                   
INFO[0005] Unpacking rootfs as cmd RUN apk add --no-cache bash requires it. 
INFO[0005] RUN apk add --no-cache bash                  
INFO[0005] Taking snapshot of full filesystem...        
INFO[0005] Resolving 12692 paths                        
INFO[0007] cmd: /bin/sh                                 
INFO[0007] args: [-c apk add --no-cache bash]           
INFO[0007] Running: [/bin/sh -c apk add --no-cache bash] 
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.2_p20200523-r0)
(2/4) Installing ncurses-libs (6.2_p20200523-r0)
(3/4) Installing readline (8.0.4-r0)
(4/4) Installing bash (5.0.17-r0)
Executing bash-5.0.17-r0.post-install
Executing busybox-1.31.1-r16.trigger
OK: 8 MiB in 18 packages
INFO[0007] Taking snapshot of full filesystem...        
INFO[0007] Resolving 12721 paths                        

If I try to run bash, I get the following error message.

/ # bash
Error loading shared library libreadline.so.8: No such file or directory (needed by /bin/bash)
Error relocating /bin/bash: unstifle_history: symbol not found
Error relocating /bin/bash: rl_make_bare_keymap: symbol not found
Error relocating /bin/bash: rl_bind_key_if_unbound_in_map: symbol not found
Error relocating /bin/bash: rl_macro_dumper: symbol not found
Error relocating /bin/bash: previous_history: symbol not found
Error relocating /bin/bash: rl_vi_end_word: symbol not found
Error relocating /bin/bash: rl_parse_and_bind: symbol not found
Error relocating /bin/bash: rl_redisplay: symbol not found
Error relocating /bin/bash: rl_push_macro_input: symbol not found
Error relocating /bin/bash: rl_bind_key_in_map: symbol not found
Error relocating /bin/bash: clear_history: symbol not found
Error relocating /bin/bash: add_history: symbol not found
Error relocating /bin/bash: rl_redraw_prompt_last_line: symbol not found
Error relocating /bin/bash: rl_function_of_keyseq_len: symbol not found
Error relocating /bin/bash: history_get: symbol not found
Error relocating /bin/bash: rl_get_keymap: symbol not found
Error relocating /bin/bash: rl_kill_text: symbol not found
Error relocating /bin/bash: remove_history: symbol not found
Error relocating /bin/bash: history_truncate_file: symbol not found
Error relocating /bin/bash: rl_generic_bind: symbol not found
Error relocating /bin/bash: rl_read_key: symbol not found
Error relocating /bin/bash: read_history: symbol not found
Error relocating /bin/bash: rl_add_defun: symbol not found
Error relocating /bin/bash: history_expand: symbol not found
Error relocating /bin/bash: rl_translate_keyseq: symbol not found
Error relocating /bin/bash: rl_get_previous_history: symbol not found
Error relocating /bin/bash: rl_forced_update_display: symbol not found
Error relocating /bin/bash: rl_read_init_file: symbol not found
Error relocating /bin/bash: rl_invoking_keyseqs: symbol not found
Error relocating /bin/bash: append_history: symbol not found
Error relocating /bin/bash: free_history_entry: symbol not found
Error relocating /bin/bash: rl_unbind_key_in_map: symbol not found
Error relocating /bin/bash: readline: symbol not found
Error relocating /bin/bash: rl_variable_value: symbol not found
Error relocating /bin/bash: history_set_pos: symbol not found
Error relocating /bin/bash: rl_unbind_function_in_map: symbol not found
Error relocating /bin/bash: read_history_range: symbol not found
Error relocating /bin/bash: history_is_stifled: symbol not found
Error relocating /bin/bash: stifle_history: symbol not found
Error relocating /bin/bash: replace_history_entry: symbol not found
Error relocating /bin/bash: rl_insert_text: symbol not found
Error relocating /bin/bash: rl_get_keymap_by_name: symbol not found
Error relocating /bin/bash: rl_set_screen_size: symbol not found
Error relocating /bin/bash: rl_vi_bWord: symbol not found
Error relocating /bin/bash: rl_get_termcap: symbol not found
Error relocating /bin/bash: rl_ding: symbol not found
Error relocating /bin/bash: where_history: symbol not found
Error relocating /bin/bash: rl_delete_text: symbol not found
Error relocating /bin/bash: rl_function_of_keyseq: symbol not found
Error relocating /bin/bash: rl_bind_keyseq: symbol not found
Error relocating /bin/bash: rl_reset_terminal: symbol not found
Error relocating /bin/bash: history_tokenize: symbol not found
Error relocating /bin/bash: rl_forward_word: symbol not found
Error relocating /bin/bash: rl_function_dumper: symbol not found
Error relocating /bin/bash: _rl_find_next_mbchar: symbol not found
Error relocating /bin/bash: rl_vi_insertion_mode: symbol not found
Error relocating /bin/bash: rl_variable_bind: symbol not found
Error relocating /bin/bash: rl_named_function: symbol not found
Error relocating /bin/bash: rl_initialize: symbol not found
Error relocating /bin/bash: rl_vi_start_inserting: symbol not found
Error relocating /bin/bash: rl_complete_internal: symbol not found
Error relocating /bin/bash: history_list: symbol not found
Error relocating /bin/bash: tilde_expand: symbol not found
Error relocating /bin/bash: rl_funmap_names: symbol not found
Error relocating /bin/bash: rl_set_keymap: symbol not found
Error relocating /bin/bash: rl_variable_dumper: symbol not found
Error relocating /bin/bash: rl_bind_keyseq_in_map: symbol not found
Error relocating /bin/bash: write_history: symbol not found
Error relocating /bin/bash: rl_on_new_line: symbol not found
Error relocating /bin/bash: rl_clear_visible_line: symbol not found
Error relocating /bin/bash: rl_completion_matches: symbol not found
Error relocating /bin/bash: rl_completion_mode: symbol not found
Error relocating /bin/bash: rl_add_undo: symbol not found
Error relocating /bin/bash: rl_cleanup_after_signal: symbol not found
Error relocating /bin/bash: rl_list_funmap_names: symbol not found
Error relocating /bin/bash: using_history: symbol not found
Error relocating /bin/bash: history_get_time: symbol not found
Error relocating /bin/bash: remove_history_range: symbol not found
Error relocating /bin/bash: rl_crlf: symbol not found
Error relocating /bin/bash: rl_filename_completion_function: symbol not found
Error relocating /bin/bash: rl_tilde_expand: symbol not found
Error relocating /bin/bash: rl_newline: symbol not found
Error relocating /bin/bash: rl_vi_editing_mode: symbol not found
Error relocating /bin/bash: rl_username_completion_function: symbol not found
Error relocating /bin/bash: rl_insert: symbol not found
Error relocating /bin/bash: rl_tab_insert: symbol not found
Error relocating /bin/bash: rl_menu_complete: symbol not found
Error relocating /bin/bash: rl_yank_last_arg: symbol not found
Error relocating /bin/bash: rl_complete: symbol not found
Error relocating /bin/bash: history_length: symbol not found
Error relocating /bin/bash: rl_completion_found_quote: symbol not found
Error relocating /bin/bash: rl_completion_type: symbol not found
Error relocating /bin/bash: rl_point: symbol not found
Error relocating /bin/bash: history_lines_written_to_file: symbol not found
Error relocating /bin/bash: history_max_entries: symbol not found
Error relocating /bin/bash: history_write_timestamps: symbol not found
Error relocating /bin/bash: rl_completion_suppress_quote: symbol not found
Error relocating /bin/bash: rl_basic_word_break_characters: symbol not found
Error relocating /bin/bash: rl_mark: symbol not found
Error relocating /bin/bash: rl_directory_rewrite_hook: symbol not found
Error relocating /bin/bash: rl_end: symbol not found
Error relocating /bin/bash: rl_directory_completion_hook: symbol not found
Error relocating /bin/bash: rl_completer_word_break_characters: symbol not found
Error relocating /bin/bash: rl_dispatching: symbol not found
Error relocating /bin/bash: rl_filename_quoting_desired: symbol not found
Error relocating /bin/bash: history_search_delimiter_chars: symbol not found
Error relocating /bin/bash: rl_executing_keyseq: symbol not found
Error relocating /bin/bash: rl_key_sequence_length: symbol not found
Error relocating /bin/bash: rl_filename_dequoting_function: symbol not found
Error relocating /bin/bash: rl_filename_rewrite_hook: symbol not found
Error relocating /bin/bash: rl_filename_stat_hook: symbol not found
Error relocating /bin/bash: vi_insertion_keymap: symbol not found
Error relocating /bin/bash: rl_prep_term_function: symbol not found
Error relocating /bin/bash: rl_menu_completion_entry_function: symbol not found
Error relocating /bin/bash: rl_attempted_completion_function: symbol not found
Error relocating /bin/bash: history_comment_char: symbol not found
Error relocating /bin/bash: rl_filename_completion_desired: symbol not found
Error relocating /bin/bash: rl_done: symbol not found
Error relocating /bin/bash: rl_completion_append_character: symbol not found
Error relocating /bin/bash: rl_sort_completion_matches: symbol not found
Error relocating /bin/bash: history_lines_read_from_file: symbol not found
Error relocating /bin/bash: emacs_ctlx_keymap: symbol not found
Error relocating /bin/bash: rl_deprep_term_function: symbol not found
Error relocating /bin/bash: rl_editing_mode: symbol not found
Error relocating /bin/bash: tilde_additional_prefixes: symbol not found
Error relocating /bin/bash: history_subst_char: symbol not found
Error relocating /bin/bash: rl_readline_state: symbol not found
Error relocating /bin/bash: rl_attempted_completion_over: symbol not found
Error relocating /bin/bash: vi_movement_keymap: symbol not found
Error relocating /bin/bash: rl_filename_quote_characters: symbol not found
Error relocating /bin/bash: rl_filename_quoting_function: symbol not found
Error relocating /bin/bash: history_quotes_inhibit_expansion: symbol not found
Error relocating /bin/bash: rl_readline_name: symbol not found
Error relocating /bin/bash: rl_line_buffer: symbol not found
Error relocating /bin/bash: emacs_meta_keymap: symbol not found
Error relocating /bin/bash: rl_char_is_quoted_p: symbol not found
Error relocating /bin/bash: rl_completion_entry_function: symbol not found
Error relocating /bin/bash: rl_last_func: symbol not found
Error relocating /bin/bash: rl_ignore_some_completions_function: symbol not found
Error relocating /bin/bash: rl_completion_invoking_key: symbol not found
Error relocating /bin/bash: rl_instream: symbol not found
Error relocating /bin/bash: tilde_expansion_preexpansion_hook: symbol not found
Error relocating /bin/bash: tilde_additional_suffixes: symbol not found
Error relocating /bin/bash: rl_completion_suppress_append: symbol not found
Error relocating /bin/bash: history_inhibit_expansion_function: symbol not found
Error relocating /bin/bash: rl_completer_quote_characters: symbol not found
Error relocating /bin/bash: rl_completion_quote_character: symbol not found
Error relocating /bin/bash: history_base: symbol not found
Error relocating /bin/bash: rl_terminal_name: symbol not found
Error relocating /bin/bash: history_expansion_char: symbol not found
Error relocating /bin/bash: rl_outstream: symbol not found
Error relocating /bin/bash: emacs_standard_keymap: symbol not found
Error relocating /bin/bash: rl_startup_hook: symbol not found
Error relocating /bin/bash: history_quoting_state: symbol not found
Error relocating /bin/bash: rl_signal_event_hook: symbol not found
Error relocating /bin/bash: rl_special_prefixes: symbol not found
Error relocating /bin/bash: rl_explicit_arg: symbol not found
Error relocating /bin/bash: rl_num_chars_to_read: symbol not found
Error relocating /bin/bash: rl_completion_mark_symlink_dirs: symbol not found

Readline is installed though

/ # apk list | grep readline
readline-8.0.4-r0 x86_64 {readline} (GPL-2.0-or-later) [installed]

If I reinstall bash within the container itself, it's working.

/ # apk del bash
WARNING: Ignoring APKINDEX.2c4ac24e.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.40a3604f.tar.gz: No such file or directory
(1/4) Purging bash (5.0.17-r0)
Executing bash-5.0.17-r0.pre-deinstall
(2/4) Purging readline (8.0.4-r0)
(3/4) Purging ncurses-libs (6.2_p20200523-r0)
(4/4) Purging ncurses-terminfo-base (6.2_p20200523-r0)
Executing busybox-1.31.1-r16.trigger
OK: 6 MiB in 14 packages
/ # apk add --no-cache bash
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/4) Installing ncurses-terminfo-base (6.2_p20200523-r0)
(2/4) Installing ncurses-libs (6.2_p20200523-r0)
(3/4) Installing readline (8.0.4-r0)
(4/4) Installing bash (5.0.17-r0)
Executing bash-5.0.17-r0.post-install
Executing busybox-1.31.1-r16.trigger
OK: 8 MiB in 18 packages
/ # bash
bash-5.0#

If I build the container using the common docker commands, it's not an issue. This is my workaround for now, but I have to install the docker tooling.

Expected behavior

I want to run bash without this error message.

To Reproduce See first section.

Additional Information

ppodevlabs commented 4 years ago

HI @chrw,

I faced the same issue today in my jenkins pipeline. after some tests i figured out this was related to the kaniko filesytem. In my pipeline i was building 2 images in serial, and the only one failing was the second one.

By adding the --cleanup --cache=false to the kaniko executor command fixed the issue.

Hope it helps

tejal29 commented 4 years ago

@pedroparraortega Kaniko pod wasn't designed to be re-used @chrw Are you re-using the same kaniko pod?

chrw commented 4 years ago

@pedroparraortega Kaniko pod wasn't designed to be re-used @chrw Are you re-using the same kaniko pod?

What do you mean by re-using the same Kaniko pod? Gitlab CI is running the official Kaniko docker image and builds the Dockerfile I mentioned above. I'm not running Gitlab CI on Kubernetes. It's a plain Ubuntu 20.04 LTS EC2 Instance with Docker installed. The Gitlab CI Runner on the Host Machine is using the Docker executor.

Thanks for the hint @pedroparraortega, I will give it a try! 😊

evgkrsk commented 3 years ago

Faced same issue with kubernetes executor when both 0.23.0 AND 1.0.0 kaniko versions messed up with one registry cache. Cache cleanup and separation in registry (--cache-repo) works for me.

evgkrsk commented 3 years ago

Hmm, I am wrong, v1.0.0 only able to reproduce it from clean cache state :-(

faddat commented 3 years ago

"me too"

Cleaning out my docker setup now and will check in.

Oyabi commented 3 years ago

I confirm that adding --cleanup --cache=false to my kaniko command resolve the issue. Thank you @pedroparraortega.

very-doge-wow commented 2 years ago

I also can't install bash in alpine. To be more precise, I can install it but the package isn't available in the target image. Adding --cleanup --cache=false sadly did not resolve the issue, so I opened an issue here: #2177