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

COPY does not keep directory structure #583

Closed
SpringMT opened this issue Feb 24, 2019 · 3 comments
Closed

COPY does not keep directory structure #583

SpringMT opened this issue Feb 24, 2019 · 3 comments
Labels
cmd/copy kind/bug Something isn't working

Comments

@SpringMT
Copy link

SpringMT commented Feb 24, 2019

Reporducing environment is below.

  • Base directory structure
% tree
.
├── Dockerfile
├── README.md
├── api
│   └── api.txt
└── cloudbuild.yaml
  • Dockerfile
FROM alpine
RUN apk add tree
RUN mkdir /app
RUN mkdir /app/api
COPY api /app/api/
RUN tree /app

Actual behavior
Build using kaniko.

COPY api /app/api/ result is below.

/app
└── api
└── api.txt
  • Build log
starting build "*********"

FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From *********/github_SpringMT_kaniko_5Ftest
* branch bb8d6d8a5d00cee2a3764cb05fdb2714a075fde0 -> FETCH_HEAD
HEAD is now at bb8d6d8 Remove WORKDIR
BUILD
Pulling image: gcr.io/kaniko-project/executor
Using default tag: latest
latest: Pulling from kaniko-project/executor
Digest: sha256:d9fe474f80b73808dc12b54f45f5fc90f7856d9fc699d4a5e79d968a1aef1a72
Status: Downloaded newer image for gcr.io/kaniko-project/executor:latest
INFO[0000] Downloading base image alpine 
2019/02/26 01:12:19 No matching credentials were found, falling back on anonymous
INFO[0001] Error while retrieving image from cache: geting file info: stat /cache/sha256:25b4d910f4b76a63a3b45d0f69a57c34157500faf6087236581eca221c62d214: no such file or directory 
INFO[0001] Downloading base image alpine 
2019/02/26 01:12:20 No matching credentials were found, falling back on anonymous
INFO[0001] Checking for cached layer *********/cache:66baeda084f3c55ee53656de11729a3954da8a831f469c87a3b6336f86e437c2... 
INFO[0002] Cache entry expired: *********/cache:66baeda084f3c55ee53656de11729a3954da8a831f469c87a3b6336f86e437c2 
INFO[0002] No cached layer found for cmd RUN apk add tree 
INFO[0002] Unpacking rootfs as cmd RUN apk add tree requires it. 
INFO[0002] Taking snapshot of full filesystem... 
INFO[0002] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0002] Skipping paths under /root/tokencache, as it is a whitelisted directory 
INFO[0002] Skipping paths under /builder/cache, as it is a whitelisted directory 
INFO[0002] Skipping paths under /builder/home, as it is a whitelisted directory 
INFO[0002] Skipping paths under /builder/outputs, as it is a whitelisted directory 
INFO[0002] Skipping paths under /var/run, as it is a whitelisted directory 
INFO[0002] Skipping paths under /dev, as it is a whitelisted directory 
INFO[0002] Skipping paths under /sys, as it is a whitelisted directory 
INFO[0002] Skipping paths under /proc, as it is a whitelisted directory 
INFO[0002] Skipping paths under /workspace, as it is a whitelisted directory 
INFO[0002] RUN apk add tree 
INFO[0002] cmd: /bin/sh 
INFO[0002] args: [-c apk add tree] 
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/1) Installing tree (1.8.0-r0)
Executing busybox-1.29.3-r10.trigger
OK: 6 MiB in 15 packages
INFO[0002] Taking snapshot of full filesystem... 
INFO[0003] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0003] Skipping paths under /root/tokencache, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/cache, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/home, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/outputs, as it is a whitelisted directory 
INFO[0003] Skipping paths under /var/run, as it is a whitelisted directory 
INFO[0003] Skipping paths under /dev, as it is a whitelisted directory 
INFO[0003] Skipping paths under /sys, as it is a whitelisted directory 
INFO[0003] Skipping paths under /proc, as it is a whitelisted directory 
INFO[0003] Skipping paths under /workspace, as it is a whitelisted directory 
INFO[0003] RUN mkdir /app 
INFO[0003] cmd: /bin/sh 
INFO[0003] args: [-c mkdir /app] 
INFO[0003] Taking snapshot of full filesystem... 
INFO[0003] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0003] Skipping paths under /root/tokencache, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/cache, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/home, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/outputs, as it is a whitelisted directory 
INFO[0003] Skipping paths under /var/run, as it is a whitelisted directory 
INFO[0003] Skipping paths under /dev, as it is a whitelisted directory 
INFO[0003] Skipping paths under /sys, as it is a whitelisted directory 
INFO[0003] Skipping paths under /proc, as it is a whitelisted directory 
INFO[0003] Skipping paths under /workspace, as it is a whitelisted directory 
INFO[0003] Pushing layer *********/cache:66baeda084f3c55ee53656de11729a3954da8a831f469c87a3b6336f86e437c2 to cache now 
INFO[0003] RUN mkdir /app/api 
INFO[0003] cmd: /bin/sh 
INFO[0003] args: [-c mkdir /app/api] 
INFO[0003] Taking snapshot of full filesystem... 
INFO[0003] Skipping paths under /kaniko, as it is a whitelisted directory 
INFO[0003] Skipping paths under /root/tokencache, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/cache, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/home, as it is a whitelisted directory 
INFO[0003] Skipping paths under /builder/outputs, as it is a whitelisted directory 
INFO[0003] Skipping paths under /var/run, as it is a whitelisted directory 
INFO[0003] Skipping paths under /dev, as it is a whitelisted directory 
INFO[0003] Skipping paths under /sys, as it is a whitelisted directory 
INFO[0003] Skipping paths under /proc, as it is a whitelisted directory 
INFO[0003] Skipping paths under /workspace, as it is a whitelisted directory 
INFO[0003] Pushing layer *********/cache:b8c0df74ce9b3795c0ea032e41744406a4e52245b72ae59e200275eb4ef4765f to cache now 
INFO[0003] Using files from context: [/workspace/api] 
INFO[0003] COPY api /app/api/ 
INFO[0003] Taking snapshot of files... 
INFO[0003] RUN tree /app 
INFO[0003] cmd: /bin/sh 
INFO[0003] args: [-c tree /app] 
/app
└── api
└── api.txt

1 directory, 1 file

Expected behavior
Build using docker.

COPY api /app/api/ result is below.

/app
└── api
    └── api.txt
  • Build log
% docker build --no-cache=true .
Sending build context to Docker daemon  95.74kB
Step 1/6 : FROM alpine
 ---> caf27325b298
Step 2/6 : RUN apk add tree
 ---> Running in 05f28a5a42e0
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/1) Installing tree (1.8.0-r0)
Executing busybox-1.29.3-r10.trigger
OK: 6 MiB in 15 packages
Removing intermediate container 05f28a5a42e0
 ---> c6bd2073cfd3
Step 3/6 : RUN mkdir /app
 ---> Running in f872aa7de7b9
Removing intermediate container f872aa7de7b9
 ---> 83bd3c1140a2
Step 4/6 : RUN mkdir /app/api
 ---> Running in 616c0dc0f512
Removing intermediate container 616c0dc0f512
 ---> eaed8b1404e7
Step 5/6 : COPY api /app/api/
 ---> 797c4f292a58
Step 6/6 : RUN tree /app
 ---> Running in 004d300b0edf
/app
└── api
    └── api.txt

1 directory, 1 file
Removing intermediate container 004d300b0edf
 ---> b52d788d4be3
Successfully built b52d788d4be3

Docker version

% docker -v
Docker version 18.09.1, build 4c52b90

To Reproduce
The reproduced environment is below repository.
https://github.com/SpringMT/kaniko_test

Steps to reproduce the behavior:

  • docker
  1. git clone https://github.com/SpringMT/kaniko_test
  2. cd kaniko_test
  3. docekr build .

Additional Information

Pulling image: gcr.io/kaniko-project/executor
Using default tag: latest
latest: Pulling from kaniko-project/executor
Digest: sha256:d9fe474f80b73808dc12b54f45f5fc90f7856d9fc699d4a5e79d968a1aef1a72
@SpringMT SpringMT changed the title COPY behavior is different from docker COPY does not keep directory structure Feb 26, 2019
@dansiviter
Copy link

dansiviter commented Mar 19, 2019

I've just run into this issue to but with copying file into directory:

COPY /acme/foo/myfile.txt /acme/foo/  # trailing slash should 'copy into', not 'copy at'

Results in:

/acme
 └─ foo  // <- the contents of the file myfile.txt is here

When it should be:

/acme
 └─ /foo
     └─ myfile.txt

@dtaniwaki
Copy link
Contributor

dtaniwaki commented Mar 20, 2019

I tried it but this issue doesn't happen with the latest commit of 1bf4421047570790ced358f60118b58709628c15.

@SpringMT
Copy link
Author

SpringMT commented Mar 20, 2019

I think this issue was resolved by #605.

@priyawadhwa priyawadhwa added cmd/copy kind/bug Something isn't working labels Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd/copy kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants