Kaniko: Empty tar image file is built

Created on 20 Feb 2019  路  4Comments  路  Source: GoogleContainerTools/kaniko

Actual behavior
I am trying to build an image in docker using kaniko.

When I used the following command to run, it returned no error and built a .tar file. However, the tar file contains only a null manifest.json file

sudo docker run -t -v $(pwd):/workdir gcr.io/kaniko-project/executor -context=/workdir --dockerfile=/workdir/Dockerfile --no-push --tarPath=/workdir/image.tar -

Expected behavior
A image.tar image file( not empty) is created.

To Reproduce
sudo docker run -t -v $(pwd):/workdir gcr.io/kaniko-project/executor --context=/workdir --dockerfile=/workdir/Dockerfile --no-push --tarPath=/workdir/image.tar

Additional Information

  • Dockerfile
FROM alpine:latest

WORKDIR home/work
COPY ["binaryA" ,"."]

EXPOSE 8000

ENTRYPOINT ["./binaryA"]
  • Build Context
/ - FolderA
|  - Dockerfile 
|  - binaryA

In which the line COPY ["binaryA", "."] will copy a binary file named binaryA

  • Kaniko Image : sha256:d9fe474f80b73808dc12b54f45f5fc90f7856d9fc699d4a5e79d968a1aef1a72

Most helpful comment

For those who encountered the same problem just add --destination instead of --no-push in the command

sudo docker run -t -v $(pwd):/workdir gcr.io/kaniko-project/executor --context=/workdir --dockerfile=/workdir/Dockerfile --tarPath=/workdir/image.tar --destination=image

All 4 comments

The following are the running msg :

sudo docker run -t -v $(pwd):/workdir gcr.io/kaniko-project/executor --dockerfile=/workdir/Dockerfile --no-push --tarPath=/workdir/authority.tar --context=/workdir
INFO[0000] Downloading base image alpine:latest         
2019/02/20 07:23:33 No matching credentials were found, falling back on anonymous
INFO[0004] Taking snapshot of full filesystem...        
INFO[0004] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0004] Skipping paths under /workdir, as it is a whitelisted directory 
INFO[0004] Skipping paths under /proc, as it is a whitelisted directory 
INFO[0004] Skipping paths under /dev, as it is a whitelisted directory 
INFO[0004] Skipping paths under /sys, as it is a whitelisted directory 
INFO[0004] WORKDIR home/work                    
INFO[0004] cmd: workdir                                 
INFO[0004] Changed working directory to home/work
INFO[0004] Creating directory home/work        
INFO[0004] Taking snapshot of files...                  
INFO[0004] Using files from context: [/workdir]         
INFO[0004] COPY ["." ,"."]                              
INFO[0004] Taking snapshot of files...                  
INFO[0005] EXPOSE 8000                                  
INFO[0005] cmd: EXPOSE                                  
INFO[0005] Adding exposed port: 8000/tcp                
INFO[0005] ENTRYPOINT ["./binary"]  

For those who encountered the same problem just add --destination instead of --no-push in the command

sudo docker run -t -v $(pwd):/workdir gcr.io/kaniko-project/executor --context=/workdir --dockerfile=/workdir/Dockerfile --tarPath=/workdir/image.tar --destination=image

Thanks, I hit same issue

I also hit this issue, however I needed to include both --no-push and --destination to get it to work, probably because I didn't provide a valid destination (I'm building somewhere without access to a registry, which is why I want to use tarPath). I think this is still an actual bug, can it be re-opened?

Reproduction script that works in the debug container:

#!/bin/sh

for t in `seq 1 3`
do
    mkdir -p "/test-${t}/out"

    cat <<-'EOF' > "/test-${t}/Dockerfile"
FROM scratch
COPY test.txt /test.txt
EOF

    cat <<-'EOF' > "/test-${t}/test.txt"
Hello, world!
EOF

done

set -x
# Test 1
executor -c /test-1 --tarPath /test-1/out/out.tar --verbosity=debug --no-push

# Test 2
executor -c /test-2 --tarPath /test-2/out/out.tar --verbosity=debug --destination=image

# Test 3
executor -c /test-3 --tarPath /test-3/out/out.tar --verbosity=debug --destination=image --no-push

# Output
tar -tvf /test-1/out/out.tar
tar -tvf /test-2/out/out.tar
tar -tvf /test-3/out/out.tar
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fkorotkov picture fkorotkov  路  3Comments

ahsannaseem picture ahsannaseem  路  3Comments

WesCossick picture WesCossick  路  3Comments

danilorsilva picture danilorsilva  路  3Comments

Vrtak-CZ picture Vrtak-CZ  路  5Comments