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

ADD of local tar fails if last layer of stage #907

Open
iciclespider opened this issue Dec 10, 2019 · 0 comments
Open

ADD of local tar fails if last layer of stage #907

iciclespider opened this issue Dec 10, 2019 · 0 comments
Labels
area/dockerfile-command For all bugs related to dockerfile file commands kind/bug Something isn't working priority/p2 High impact feature/bug. Will get a lot of users happy

Comments

@iciclespider
Copy link

iciclespider commented Dec 10, 2019

Actual behavior

When an ADD command of a local tar archive is performed as the last command of the Dockerfile, the contents of the local tar are not in the image.

Expected behavior

I expect the resulting image to contain the contents of the local tar archive.

To Reproduce

  1. While in a directory with the following Dockerfile:
FROM alpine
ADD localtar.tar /localtar
  1. Create a localtar.tar archive using:
$ tar cf localtar.tar Dockerfile
  1. Build the image using docker:
$ docker build -t docker-built .
Sending build context to Docker daemon  4.608kB
Step 1/2 : FROM alpine
 ---> 965ea09ff2eb
Step 2/2 : ADD localtar.tar /localtar
 ---> Using cache
 ---> 34a4fcd140e7
Successfully built 34a4fcd140e7
Successfully tagged docker-built:latest
  1. Build the image using kaniko:
$ docker run --rm -v $PWD:/workspace/ gcr.io/kaniko-project/executor:latest --context dir:///workspace/ --destination 172.17.0.2:5000/kaniko-built
INFO[0000] Resolved base name alpine to alpine
INFO[0000] Resolved base name alpine to alpine
INFO[0000] Downloading base image alpine
INFO[0002] Error while retrieving image from cache: getting file info: stat /cache/sha256:e4355b66995c96b4b468159fc5c7e3540fcef961189ca13fee877798649f531a: no such file or directory
INFO[0002] Downloading base image alpine
INFO[0004] Built cross stage deps: map[]
INFO[0004] Downloading base image alpine
INFO[0005] Error while retrieving image from cache: getting file info: stat /cache/sha256:e4355b66995c96b4b468159fc5c7e3540fcef961189ca13fee877798649f531a: no such file or directory
INFO[0005] Downloading base image alpine
INFO[0007] Skipping unpacking as no commands require it.
INFO[0007] Taking snapshot of full filesystem...
INFO[0007] Using files from context: [/workspace/localtar.tar]
INFO[0007] ADD localtar.tar /localtar
INFO[0007] Unpacking local tar archive localtar.tar to /localtar
INFO[0007] Taking snapshot of files...
  1. Pull the just built kaniko image:
$ docker pull 172.17.0.2:5000/kaniko-built
Using default tag: latest
latest: Pulling from kaniko-built
89d9c30c1d48: Already exists
1a950994201c: Pull complete
Digest: sha256:8edff3bcfb535ed6b081bc49b706228991a4a9b9bbe1fd8111ac9e7e9a052d33
Status: Downloaded newer image for 172.17.0.2:5000/kaniko-built:latest
172.17.0.2:5000/kaniko-built:latest
  1. Examine the docker built image's /localtar directory:
$ docker run --rm docker-built ls -al /localtar
total 12
drwxr-xr-x    2 root     root          4096 Dec 10 03:54 .
drwxr-xr-x    1 root     root          4096 Dec 10 04:18 ..
-rw-r--r--    1 502      dialout         39 Dec 10 03:50 Dockerfile
  1. Examine the kaniko built image's /localtar directory:
$ docker run --rm 172.17.0.2:5000/kaniko-built ls -al /localtar
total 8
drwxr-xr-x    2 root     root          4096 Dec 10 04:26 .
drwxr-xr-x    1 root     root          4096 Dec 10 04:29 ..

The resulting kaniko built image does not contain the tar archive's contents, whereas the docker built image does.

Additional Information

  • Dockerfile
FROM alpine
ADD localtar.tar /localtar
  • Build Context
$ ls -l
total 16
-rw-r--r--  1 iciclespider  staff    39 Dec  9 17:54 Dockerfile
-rw-r--r--  1 iciclespider  staff  2048 Dec  9 18:24 localtar.tar

localtar.tar can be created using:

$ tar cf localtar.tar Dockerfile
  • Pull Requests

The following Pull Request fixes this issue: Fix Ability for ADD to unTar a file

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
Please check if the build works in docker but not in kaniko
Please check if this error is seen when you use --cache flag
Please check if your dockerfile is a multistage dockerfile
@cvgw cvgw added area/dockerfile-command For all bugs related to dockerfile file commands kind/bug Something isn't working labels Dec 21, 2019
@tejal29 tejal29 added this to the GA Release v1.0.0 milestone Jan 22, 2020
@tejal29 tejal29 added the priority/p2 High impact feature/bug. Will get a lot of users happy label Jan 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dockerfile-command For all bugs related to dockerfile file commands kind/bug Something isn't working priority/p2 High impact feature/bug. Will get a lot of users happy
Projects
None yet
Development

No branches or pull requests

3 participants