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

When --ignorefile is used and it's empty, it causes error with podman build, maybe falls back to default ignorefile. #25147

Open
abraithwaite opened this issue Jan 29, 2025 · 1 comment · May be fixed by #25161
Labels
kind/bug Categorizes issue or PR as related to a bug. macos MacOS (OSX) related remote Problem is in podman-remote

Comments

@abraithwaite
Copy link

abraithwaite commented Jan 29, 2025

Issue Description

When trying to build a podman container, I noticed that a file wasn't being included that I expected to be there. Upon closer investigation, I noticed that a .dockerignore was present in the root directory causing the file not to be copied.

I tried overriding with --ignorefile /dev/null and continued to get the error.

I narrowed it down to what I believe to be the root cause: an empty ignorefile seems to fallback to the default docker ignorefile.

I'd expect if the --ignorefile flag is explicitly set to an empty file, then it should not load the original ignorefile.

Steps to reproduce the issue

abraithwaite at gibson in ~/Projects/github.com/runreveal/example
23:10:39 $ tree -a
.
├── .dockerignore
├── Dockerfile
├── dist
│   ├── altignore.txt
│   ├── asdf1.txt
│   └── asdf2.txt
├── test1.txt
└── test2.txt

2 directories, 6 files

abraithwaite at gibson in ~/Projects/github.com/runreveal/example
23:10:43 $ cat dist/altignore.txt


abraithwaite at gibson in ~/Projects/github.com/runreveal/example
23:14:56 $ cat .dockerignore
test2.txt
**/dist

abraithwaite at gibson in ~/Projects/github.com/runreveal/example
23:10:47 $ cat Dockerfile
FROM alpine:latest
COPY dist/asdf* /tmp/

abraithwaite at gibson in ~/Projects/github.com/runreveal/example
23:11:25 $ podman build --no-cache -t testignore --ignorefile dist/altignore.txt .
STEP 1/2: FROM alpine:latest
STEP 2/2: COPY dist/asdf* /tmp/
Error: building at STEP "COPY dist/asdf* /tmp/": checking on sources under "/var/tmp/libpod_builder1578895609/build": Rel: can't make  relative to /var/tmp/libpod_builder1578895609/build; copier: stat: ["/dist/asdf*"]: no such file or directory

Describe the results you received

A somewhat obscure error is thrown and I was left wondering what the heck was happening.

Error: building at STEP "COPY dist/asdf* /tmp/": checking on sources under "/var/tmp/libpod_builder1578895609/build": Rel: can't make  relative to /var/tmp/libpod_builder1578895609/build; copier: stat: ["/dist/asdf*"]: no such file or directory

Describe the results you expected

I expect that: when passing in an empty ignore file, the original .dockerignore or .containerignore is overridden and not parsed.

As such, an empty ignore file shouldn't ignore anything.

The use case is that I want to conditionally include files in some builds that are excluded by default for us in the ignorefile.

podman info output

host:
  arch: arm64
  buildahVersion: 1.35.3
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - pids
  - rdma
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.10-1.fc39.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: '
  cpuUtilization:
    idlePercent: 88.47
    systemPercent: 2.83
    userPercent: 8.7
  cpus: 4
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: coreos
    version: "39"
  eventLogger: journald
  freeLocks: 1597
  hostname: localhost.localdomain
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.8.4-200.fc39.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 2460356608
  memTotal: 8301178880
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.10.0-1.fc39.aarch64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.10.0
    package: netavark-1.10.3-1.fc39.aarch64
    path: /usr/libexec/podman/netavark
    version: netavark 1.10.3
  ociRuntime:
    name: crun
    package: crun-1.14.4-1.fc39.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.14.4
      commit: a220ca661ce078f2c37b38c92e66cf66c012d9c1
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20240405.g954589b-1.fc39.aarch64
    version: |
      pasta 0^20240405.g954589b-1.fc39.aarch64-pasta
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  rootlessNetworkCmd: ""
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.2-1.fc39.aarch64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 0
  swapTotal: 0
  uptime: 3h 26m 28.00s (Approximately 0.12 days)
  variant: v8
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 17
    paused: 0
    running: 5
    stopped: 12
  graphDriverName: overlay
  graphOptions:
    overlay.imagestore: /usr/lib/containers/storage
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 106769133568
  graphRootUsed: 60304642048
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 199
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.0.2
  Built: 1713312000
  BuiltTime: Tue Apr 16 17:00:00 2024
  GitCommit: ""
  GoVersion: go1.21.9
  Os: linux
  OsArch: linux/arm64
  Version: 5.0.2

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

On macOS, also using podman desktop.

23:13:02 $ podman version
Client:       Podman Engine
Version:      5.3.2
API Version:  5.3.2
Go Version:   go1.23.5
Git Commit:   85043bb1a3818102194afa82845cb63841067c9c
Built:        Tue Jan 21 10:41:34 2025
OS/Arch:      darwin/arm64

Server:       Podman Engine
Version:      5.0.2
API Version:  5.0.2
Go Version:   go1.21.9
Built:        Tue Apr 16 17:00:00 2024
OS/Arch:      linux/arm64

Additional information

No response

@abraithwaite abraithwaite added the kind/bug Categorizes issue or PR as related to a bug. label Jan 29, 2025
@github-actions github-actions bot added macos MacOS (OSX) related remote Problem is in podman-remote labels Jan 29, 2025
@abraithwaite abraithwaite changed the title When --ignorefile is used and it's empty, it causes error with podman build When --ignorefile is used and it's empty, it causes error with podman build, maybe falls back to default ignorefile. Jan 29, 2025
@danishprakash
Copy link
Contributor

I agree that when --ignorefile is present, it should take precedence over any other default fallbacks. There seems to be a bug where we don't pass the ignorefile to buildah during build causing buildah to ignore empty files even though they are specified explicitly.

This PR should fix this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. macos MacOS (OSX) related remote Problem is in podman-remote
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants