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

podman build with --build-arg-file behaves differently from source or ContainerFile #5945

Open
NemoTR opened this issue Jan 26, 2025 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@NemoTR
Copy link

NemoTR commented Jan 26, 2025

Issue Description

I don't know if this is a bug or not, but I think this does not make sense:

  • source needs the key=value entries in the file to have quotes if there is a space in the value.
  • podman build --build-arg-file needs the key=value entries in the file to have no quotes either there is spaces in the value or not.

I read Containerfile reference and podman build reference but gained little about this.

My Containerfile:

FROM ubuntu:24.04

ARG STRING
ARG STRING1

RUN echo ${STRING}
RUN echo "${STRING}"

RUN echo ${STRING1}
RUN echo "${STRING1}"

My argfile.conf:

STRING="123 123"
STRING1=123 123

Now I build:

$ podman build --no-cache -t test_image --build-arg-file=argfile.conf .
STEP 1/7: FROM ubuntu:24.04
STEP 2/7: ARG STRING
--> 5e229dcb25af
STEP 3/7: ARG STRING1
--> 8c9652c4e0c4
STEP 4/7: RUN echo ${STRING}
"123 123"
--> 74d44f2fbe04
STEP 5/7: RUN echo "${STRING}"
"123 123"
--> 24f700dd7a74
STEP 6/7: RUN echo ${STRING1}
123 123
--> 75f15980678e
STEP 7/7: RUN echo "${STRING1}"
123 123
COMMIT test_image
--> 94d2b6bbf5c8
Successfully tagged localhost/test_image:latest
94d2b6bbf5c8f7a9b4edbbe692c62e4d1fedae08eb9a8755638736f6f9de5ead

And than I use source

$ source argfile.conf 
123: command not found

Why RUN echo "${STRING}" outputs "123 123" that has quotes?
I simply tried:

$ echo ""123 123""
123 123
$ echo "\"123 123\""
"123 123"

Seems the ARG STRING is actually \"123 123\", is this a bug? Or why is it designed like this?

Best regards!

Steps to reproduce the issue

Steps to reproduce the issue
1.
Containerfile:

FROM ubuntu:24.04

ARG STRING
ARG STRING1

RUN echo ${STRING}
RUN echo "${STRING}"

RUN echo ${STRING1}
RUN echo "${STRING1}"

argfile.conf:

STRING="123 123"
STRING1=123 123
  1. podman build --no-cache -t test_image --build-arg-file=argfile.conf .
  2. source argfile.conf

Describe the results you received

The ARG STRING is actually \"123 123\". While the ARG STRING1 is actually what I need for podman build but it can't be load by source.

Describe the results you expected

I expect podman build --build-arg-file to ignore quotes.

podman info output

$ podman info
host:
  arch: amd64
  buildahVersion: 1.33.7
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon_2.1.10+ds1-1build2_amd64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: unknown'
  cpuUtilization:
    idlePercent: 99.85
    systemPercent: 0.06
    userPercent: 0.09
  cpus: 32
  databaseBackend: sqlite
  distribution:
    codename: noble
    distribution: ubuntu
    version: "24.04"
  eventLogger: journald
  freeLocks: 2044
  hostname: sev-host
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.8.0-51-generic
  linkmode: dynamic
  logDriver: journald
  memFree: 151873798144
  memTotal: 236234715136
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns_1.4.0-5_amd64
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.4.0
    package: netavark_1.4.0-4_amd64
    path: /usr/lib/podman/netavark
    version: netavark 1.4.0
  ociRuntime:
    name: runc
    package: runc_1.1.12-0ubuntu3.1_amd64
    path: /usr/bin/runc
    version: |-
      runc version 1.1.12-0ubuntu3.1
      spec: 1.0.2-dev
      go: go1.22.2
      libseccomp: 2.5.5
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt_0.0~git20240220.1e6f92b-1_amd64
    version: |
      pasta unknown version
      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/user/1000/podman/podman.sock
  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: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns_1.2.1-1build2_amd64
    version: |-
      slirp4netns version 1.2.1
      commit: 09e31e92fa3d2a1d3ca261adaeb012c8d75a8194
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.5
  swapFree: 8589930496
  swapTotal: 8589930496
  uptime: 49h 47m 24.00s (Approximately 2.04 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  docker.io:
    Blocked: false
    Insecure: false
    Location: docker.io
    MirrorByDigestOnly: false
    Mirrors:
    - Insecure: false
      Location: docker.1ms.run
      PullFromMirror: ""
    - Insecure: false
      Location: docker.xuanyuan.me
      PullFromMirror: ""
    Prefix: docker.io
    PullFromMirror: ""
store:
  configFile: /home/server/.config/containers/storage.conf
  containerStore:
    number: 4
    paused: 0
    running: 4
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/server/.local/share/containers/storage
  graphRootAllocated: 1966736678912
  graphRootUsed: 881239289856
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 444
  runRoot: /tmp/containers-user-1000/containers
  transientStore: false
  volumePath: /home/server/.local/share/containers/storage/volumes
version:
  APIVersion: 4.9.3
  Built: 0
  BuiltTime: Thu Jan  1 00:00:00 1970
  GitCommit: ""
  GoVersion: go1.22.2
  Os: linux
  OsArch: linux/amd64
  Version: 4.9.3

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

No

Additional environment details

No response

Additional information

No response

@NemoTR NemoTR added the kind/bug Categorizes issue or PR as related to a bug. label Jan 26, 2025
@NemoTR
Copy link
Author

NemoTR commented Jan 27, 2025

I found that using ARG in ContainerFile needs quotes for strings with whitespace:

ARG S1=123 234
ARG S2="123 234"
RUN echo "${S1}"
RUN echo "${S2}"
STEP 22/25: ARG S1=123 234
--> a473e74a4dc4
STEP 23/25: ARG S2="123 234"
--> 404ba7dc2a3a
STEP 24/25: RUN echo "${S1}"
123
--> 8cbba6926ac5
STEP 25/25: RUN echo "${S2}"
123 234

So the behavior of treating quotes between defining ARG in ContainerFile and defining ARG through --build-arg-file is not the same, as we can`t use any quote for strings with whitespace in argfile.conf.

@NemoTR NemoTR changed the title podman build with --build-arg-file behaves differently from source podman build with --build-arg-file behaves differently from source or ContainerFile Jan 27, 2025
@NemoTR NemoTR changed the title podman build with --build-arg-file behaves differently from source or ContainerFile podman build with --build-arg-file behaves differently from source or ContainerFile Jan 27, 2025
@rhatdan rhatdan transferred this issue from containers/podman Jan 27, 2025
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.
Projects
None yet
Development

No branches or pull requests

1 participant