podman-py icon indicating copy to clipboard operation
podman-py copied to clipboard

No such file or directory error when building image

Open k-yarovoy-samsung opened this issue 2 years ago • 2 comments

Have met a problem during building an image through podman-py:

File "/usr/local/lib/python3.8/site-packages/podman/domain/images_build.py", line 89, in build
    params["dockerfile"] = api.prepare_containerfile(kwargs["path"], params["dockerfile"])

File "/usr/local/lib/python3.8/site-packages/podman/api/tar_utils.py", line 50, in prepare_containerfile
    shutil.copy2(dockerfile_path, proxy_path, follow_symlinks=False)

File "/usr/lib64/python3.8/shutil.py", line 435, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)

File "/usr/lib64/python3.8/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:

FileNotFoundError: [Errno 2] No such file or directory: '.containerfile.7482d90f40a649bde91353e5326d5a698053219c'

It appears if path parameter for images.build is set, but dockerfile isn't.

Looked a bit into podman-py code and found probable cause of this issue in podman-py/podman/api/tar_utils/prepare_containerfile:

proxy_path = anchor_path / f".containerfile.{random.getrandbits(160):x}"
shutil.copy2(dockerfile_path, proxy_path, follow_symlinks=False)
return proxy_path.name

It seems, that between creating path and copying - there should be creation of temporary file.

k-yarovoy-samsung avatar May 18 '22 14:05 k-yarovoy-samsung

did anybody have a look at this?

artificial-intelligence avatar Sep 14 '23 17:09 artificial-intelligence

@floutok PTAL

rhatdan avatar Sep 18 '23 14:09 rhatdan