uber-archive / makisu

Fast and flexible Docker image building tool, works in unprivileged containerized environments like Mesos and Kubernetes.
Apache License 2.0
2.41k stars 156 forks source link

rm from image don't work #310

Closed sbvitok closed 4 years ago

sbvitok commented 4 years ago

Describe the bug RUN rm -vf /etc/yum.repos.d/* do not delete files

To Reproduce

viktor@viktor:~/skopeo$ cat Dockerfile
FROM centos:7
RUN rm -vf /etc/yum.repos.d/*
RUN ls -la /etc/yum.repos.d/
viktor@viktor:~/skopeo$ 
function makisu_build() {
    makisu_version=${MAKISU_VERSION:-latest}
    cd ${@: -1}
    docker run -i --rm --net host \
        -v /var/run/docker.sock:/docker.sock \
        -e DOCKER_HOST=unix:///docker.sock \
        -v $(pwd):/makisu-context \
        -v /tmp/makisu-storage:/makisu-storage \
        gcr.io/uber-container-tools/makisu:$makisu_version build \
            --commit=explicit \
            --modifyfs=true \
            --load \
            ${@:1:${#@}-1} /makisu-context
    cd -
}

makisu_build -t myimage .

Log:

Unable to find image 'gcr.io/uber-container-tools/makisu:latest' locally
latest: Pulling from uber-container-tools/makisu
b3399c6d8f6e: Pull complete 
b917792f5627: Pull complete 
Digest: sha256:4cf8eed574a4721e05d2d183d269233ad609048f36555880f8414a5952ac4a1e
Status: Downloaded newer image for gcr.io/uber-container-tools/makisu:latest
{"level":"info","ts":1584001610.9922383,"msg":"Starting Makisu build (version=v0.1.14)"}
{"level":"info","ts":1584001610.992901,"msg":"Using build context: /makisu-context"}
{"level":"info","ts":1584001610.9929953,"msg":"Using local file at /makisu-storage/cache_key_value.json for cacheID storage"}
{"level":"info","ts":1584001610.993019,"msg":"No registry information provided, using cached layers"}
{"level":"info","ts":1584001610.9931283,"msg":"* Stage 1/1 : (alias=0,latestfetched=-1)"}
{"level":"info","ts":1584001610.993147,"msg":"* Step 1/3 (commit,modifyfs) : FROM centos:7  (793cfec8)"}
{"level":"info","ts":1584001610.9931998,"msg":"* Started pulling image index.docker.io/library/centos:7"}
{"level":"info","ts":1584001612.9689603,"msg":"* Started pulling layer index.docker.io/library/centos:sha256:ab5ef0e5819490abe86106fd9f4381123e37a03e80e650be39f7938d30ecb530"}
{"level":"info","ts":1584001613.372902,"msg":"* Started pulling layer index.docker.io/library/centos:sha256:5e35e350aded98340bc8fcb0ba392d809c807bc3eb5c618d4a0674d98d88bccd"}
{"level":"info","ts":1584001614.0140715,"msg":"* Finished pulling layer library/centos:5e35e350aded98340bc8fcb0ba392d809c807bc3eb5c618d4a0674d98d88bccd"}
{"level":"info","ts":1584001618.0624764,"msg":"* Finished pulling layer library/centos:ab5ef0e5819490abe86106fd9f4381123e37a03e80e650be39f7938d30ecb530"}
{"level":"info","ts":1584001618.062845,"msg":"* Pulled image index.docker.io/library/centos:7","duration":7.069613329}
{"level":"info","ts":1584001618.065863,"msg":"* Processing FROM layer ab5ef0e5819490abe86106fd9f4381123e37a03e80e650be39f7938d30ecb530"}
{"level":"info","ts":1584001620.9950323,"msg":"* Untarred 10735 files to /","duration":2.929}
{"level":"info","ts":1584001621.3382373,"msg":"* Merged 10735 headers from tar to memfs"}
{"level":"info","ts":1584001621.3382676,"msg":"* Executed FROM centos:7  (793cfec8)","duration":10.345111911}
{"level":"info","ts":1584001621.3385255,"msg":"* Committed gzipped layer sha256:ab5ef0e5819490abe86106fd9f4381123e37a03e80e650be39f7938d30ecb530 (75780712 bytes)"}
{"level":"info","ts":1584001621.3385367,"msg":"* Pushing with cache ID 793cfec8"}
{"level":"info","ts":1584001621.338705,"msg":"* Step 2/3 (modifyfs) : RUN rm -vf /etc/yum.repos.d/*  (a4de2c2e)"}
{"level":"info","ts":1584001621.3407612,"msg":"removed '/etc/yum.repos.d/CentOS-Base.repo'\nremoved '/etc/yum.repos.d/CentOS-CR.repo'\nremoved '/etc/yum.repos.d/CentOS-Debuginfo.repo'\nremoved '/etc/yum.repos.d/CentOS-Media.repo'\nremoved '/etc/yum.repos.d/CentOS-Sources.repo'\nremoved '/etc/yum.repos.d/CentOS-Vault.repo'\nremoved '/etc/yum.repos.d/CentOS-fasttrack.repo'\n"}
{"level":"info","ts":1584001621.3409705,"msg":"* Executed RUN rm -vf /etc/yum.repos.d/*  (a4de2c2e)","duration":0.002247052}
{"level":"info","ts":1584001621.3410249,"msg":"* Not committing step RUN rm -vf /etc/yum.repos.d/*  (a4de2c2e)"}
{"level":"info","ts":1584001621.3413975,"msg":"* Step 3/3 (commit,modifyfs) : RUN ls -la /etc/yum.repos.d/  (a8d9861b)"}
{"level":"info","ts":1584001621.3441672,"msg":"total 8\ndrwxr-xr-x 2 root root 4096 Mar 12 08:27 .\ndrwxr-xr-x 1 root root 4096 Oct  1 01:16 ..\n"}
{"level":"info","ts":1584001621.3444872,"msg":"* Executed RUN ls -la /etc/yum.repos.d/  (a8d9861b)","duration":0.003066722}
{"level":"info","ts":1584001622.472696,"msg":"* Collecting filesystem diff"}
{"level":"info","ts":1584001622.9690194,"msg":"* Collected diff: 2639 files found","duration":0.496}
{"level":"info","ts":1584001623.1695855,"msg":"* Created layer by scanning filesystem; 2639 files found"}
{"level":"info","ts":1584001623.1705265,"msg":"* Committed gzipped layer sha256:4113c0e748f1d67bcb1863cabcd607b09a58030fe90957997248533595da4f8f (2564597 bytes)"}
{"level":"info","ts":1584001623.17054,"msg":"* Pushing with cache ID a8d9861b"}
{"level":"error","ts":1584001623.513886,"msg":"Failed to push cache: registry client not configured to push cache; registry client not configured to push cache"}
{"level":"info","ts":1584001623.5143762,"msg":"Computed total image size 78345309","total_image_size":78345309}
{"level":"info","ts":1584001623.51439,"msg":"Successfully built image myimage:latest"}
{"level":"info","ts":1584001623.5143943,"msg":"Loading image myimage:latest"}
{"level":"info","ts":1584001623.5145717,"msg":"Image tarrer dir: /makisu-storage/sandbox/sandbox243799103/myimage/latest"}
{"level":"info","ts":1584001625.1112688,"msg":"Successfully loaded image myimage:latest"}
{"level":"info","ts":1584001625.111357,"msg":"Finished building myimage:latest"}
/home/viktor/skopeo
$ docker run --rm myimage:latest ls -la /etc/yum.repos.d/
drwxr-xr-x 1 root root 4096 Mar 12 08:27 .
drwxr-xr-x 1 root root 4096 Mar 12 08:28 ..
-rw-r--r-- 1 root root 1664 Sep  5  2019 CentOS-Base.repo
-rw-r--r-- 1 root root 1309 Sep  5  2019 CentOS-CR.repo
-rw-r--r-- 1 root root  649 Sep  5  2019 CentOS-Debuginfo.repo
-rw-r--r-- 1 root root  630 Sep  5  2019 CentOS-Media.repo
-rw-r--r-- 1 root root 1331 Sep  5  2019 CentOS-Sources.repo
-rw-r--r-- 1 root root 6639 Sep  5  2019 CentOS-Vault.repo
-rw-r--r-- 1 root root  314 Sep  5  2019 CentOS-fasttrack.repo

Expected behavior docker run --rm myimage:latest ls -la /etc/yum.repos.d/ must display 0 files

sbvitok commented 4 years ago

any news?

yiranwang52 commented 4 years ago

we are seeing this issue in our production environment too; working on fix.