Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Kaniko ADD instruction not preserve permissions via chmod argument #2850

@ranebull

Description

@ranebull

Actual behavior
ADD Dockerfile instruction not preserve permissions with chmod argument usage.

Expected behavior
ADD Dockerfile instruction with chmod argument preserve permissions

To Reproduce
Steps to reproduce the behavior:

  1. Build Dockerfile:
FROM alpine:latest

ADD --chmod=0755 https://github.com/GoogleContainerTools/kaniko/blob/main/benchmark.sh /usr/local/bin

# Check permissions
RUN ls -al /usr/local/bin/
  1. Get output:
/workspace # executor -c . --no-push
INFO[0000] Retrieving image manifest alpine:latest      
INFO[0000] Retrieving image alpine:latest from registry index.docker.io 
INFO[0022] Built cross stage deps: map[]                
INFO[0022] Retrieving image manifest alpine:latest      
INFO[0022] Returning cached image manifest              
INFO[0022] Executing 0 build triggers                   
INFO[0022] Building stage 'alpine:latest' [idx: '0', base-idx: '-1'] 
INFO[0022] Unpacking rootfs as cmd ADD --chmod=0755 https://github.com/GoogleContainerTools/kaniko/blob/main/benchmark.sh /usr/local/bin requires it. 
INFO[0027] Using files from context: []                 
INFO[0027] ADD --chmod=0755 https://github.com/GoogleContainerTools/kaniko/blob/main/benchmark.sh /usr/local/bin 
INFO[0027] Adding remote URL https://github.com/GoogleContainerTools/kaniko/blob/main/benchmark.sh to /usr/local/bin/benchmark.sh 
INFO[0033] Taking snapshot of files...                  
INFO[0033] RUN ls -al /usr/local/bin/                   
INFO[0033] Initializing snapshotter ...                 
INFO[0033] Taking snapshot of full filesystem...        
INFO[0033] Cmd: /bin/sh                                 
INFO[0033] Args: [-c ls -al /usr/local/bin/]            
INFO[0033] Running: [/bin/sh -c ls -al /usr/local/bin/] 
total 124
drwxr-xr-x    1 root     root            24 Nov 13 13:56 .
drwxr-xr-x    1 root     root            22 Nov 13 13:56 ..
-rw-------    1 root     root        126793 Nov 13 13:56 benchmark.sh
INFO[0033] Taking snapshot of full filesystem...        
INFO[0033] No files were changed, appending empty layer to config. No layer added to image. 
INFO[0033] Skipping push to container registry due to --no-push flag
  1. File have permissions 0600, but must have 0755

Additional Information

  • Dockerfile
FROM alpine:latest
ADD --chmod=0755 https://github.com/GoogleContainerTools/kaniko/blob/main/benchmark.sh /usr/local/bin
RUN ls -al /usr/local/bin/

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
  • - [Yes]
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
  • - [No]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions