buildah icon indicating copy to clipboard operation
buildah copied to clipboard

Inconsistent behavior with docker when using COPY and non existing file

Open netsandbox opened this issue 1 year ago • 9 comments

Inconsistent behavior with docker when using COPY and non existing file.

FROM scratch

COPY nonexistingfile.* .

While docker builds the above Containerfile, podman fails with:

STEP 1/2: FROM scratch
STEP 2/2: COPY nonexistingfile.* .
Error: error building at STEP "COPY nonexistingfile.* .": checking on sources under "/home/me/code/podman-copy": Rel: can't make  relative to /home/me/code/podman-copy; copier: stat: ["/nonexistingfile.*"]: no such file or directory

Steps to reproduce the issue:

  1. docker build -t test -f Containerfile . (works)
  2. podman build -t test -f Containerfile . (fails)

Describe the results you received:

Podman fails when using COPY with non existing files.

Describe the results you expected:

Podman should build when using COPY with non existing files, as docker does.

Output of rpm -q buildah or apt list buildah:

buildah/jammy,now 1.23.1+ds1-2 amd64 [installed,automatic]

Output of buildah version:

Version:         1.23.1
Go Version:      go1.17
Image Spec:      1.0.1
Runtime Spec:    1.0.2-dev
CNI Spec:        0.4.0
libcni Version:  
image Version:   5.16.0
Git Commit:      
Built:           Thu Jan  1 01:00:00 1970
OS/Arch:         linux/amd64
BuildPlatform:   linux/amd64

Output of podman version if reporting a podman build issue:

Version:      3.4.4
API Version:  3.4.4
Go Version:   go1.18.1
Built:        Thu Jan  1 01:00:00 1970
OS/Arch:      linux/amd64

Output of docker version:

Client: Docker Engine - Community
 Version:           27.1.2
 API version:       1.46
 Go version:        go1.21.13
 Git commit:        d01f264
 Built:             Mon Aug 12 11:50:12 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.1.2
  API version:      1.46 (minimum version 1.24)
  Go version:       go1.21.13
  Git commit:       f9522e5
  Built:            Mon Aug 12 11:50:12 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.20
  GitCommit:        8fc6bcff51318944179630522a095cc9dbf9f353
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Output of cat /etc/*release:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.4 LTS"
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Output of uname -a:

Linux me 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Output of cat /etc/containers/storage.conf:

cat: /etc/containers/storage.conf: No such file or directory

netsandbox avatar Aug 27 '24 14:08 netsandbox

It looks like this changed between classic docker build and the newer BuildKit-based docker build, as I get different results by setting DOCKER_BUILDKIT to 0 or 1 in the environment before invoking docker build.

nalind avatar Aug 28 '24 19:08 nalind

We only care about DOCKER_BUILDKIT=1 since we are moving to the new standard.

rhatdan avatar Aug 29 '24 10:08 rhatdan

It didn't work with DOCKER_BUILDKIT=0, but it works with DOCKER_BUILDKIT=1

$ DOCKER_BUILDKIT=0 docker build -f Containerfile .
DEPRECATED: The legacy builder is deprecated and will be removed in a future release.
            BuildKit is currently disabled; enable it by removing the DOCKER_BUILDKIT=0
            environment-variable.

Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM scratch
 ---> 
Step 2/2 : COPY nonexistingfile.* .
COPY failed: no source files were specified
$ DOCKER_BUILDKIT=1 docker build -f Containerfile .
#0 building with "default" instance using docker driver

#1 [internal] load build definition from Containerfile
#1 transferring dockerfile: 79B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 2B done
#2 DONE 0.0s

#3 [internal] load build context
#3 transferring context: 2B done
#3 DONE 0.0s

#4 [1/1] COPY nonexistingfile.* .
#4 CACHED

#5 exporting to image
#5 exporting layers done
#5 writing image sha256:810b55b8671ad59944575835a0ddae1ea28ef3c85bed153df3441f7a08e504f7 done
#5 DONE 0.0s

netsandbox avatar Aug 30 '24 05:08 netsandbox

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Sep 30 '24 00:09 github-actions[bot]

@rhatdan any news regarding this?

netsandbox avatar Oct 28 '24 07:10 netsandbox

A friendly reminder that this issue had no activity for 30 days.

github-actions[bot] avatar Nov 28 '24 00:11 github-actions[bot]

This isn’t „stale“ - same issue as before, there’s just no activity because there’s nothing more to add.

AliveDevil avatar May 30 '25 13:05 AliveDevil

Interested in opening a PR?

rhatdan avatar May 30 '25 14:05 rhatdan

I'd love to, especially because Debian 13 is around the corner, and missing this for another release term would bug me a lot. But, I'm not really fluent with anything Go, so it might take a hot minute.

Just for my reference, this should be reproducible with buildah copy missing.* target? Is #5902 by chance the same underlying root cause? So it would be this and here addressed at once?

AliveDevil avatar May 30 '25 15:05 AliveDevil