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

--build-arg is not being set from environment #9798

Closed
smac89 opened this issue Mar 24, 2021 · 6 comments
Closed

--build-arg is not being set from environment #9798

smac89 opened this issue Mar 24, 2021 · 6 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@smac89
Copy link

smac89 commented Mar 24, 2021

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

Steps to reproduce the issue:

  1. In the current shell, I export a variable:
export CFLAGS='-02 -pipe'
  1. Next, I run a script which ends up running the command:
podman --build-arg CFLAGS --file myDockerFile .
  1. Inside the DockerFile, I have the following:
# default value
ARG CFLAGS='-01'
...
RUN echo "CFLAGS=${CFLAGS}"

Describe the results you received:
The output still says: CFLAGS=-O1

Describe the results you expected:
The correct output should be: CFLAGS=-O2 -pipe

I should also add that this happens even if I had not given the ARG a default value.

Output of podman version:

podman version 3.0.1

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.19.4
  cgroupManager: cgroupfs
  cgroupVersion: v1
  conmon:
    package: /usr/bin/conmon is owned by conmon 1:2.0.27-1
    path: /usr/bin/conmon
    version: 'conmon version 2.0.27, commit: 65fad4bfcb250df0435ea668017e643e7f462155'
  cpus: 12
  distribution:
    distribution: arcolinux
    version: unknown
  eventLogger: journald
  hostname: ArcoB
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 10000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 10000
      size: 65536
  kernel: 5.11.7-arch1-1
  linkmode: dynamic
  memFree: 5325000704
  memTotal: 41711161344
  ociRuntime:
    name: crun
    package: /usr/bin/crun is owned by crun 0.18-1
    path: /usr/bin/crun
    version: |-
      crun version 0.18
      commit: 808420efe3dc2b44d6db9f1a3fac8361dde42a95
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +YAJL
  os: linux
  remoteSocket:
    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
    selinuxEnabled: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: /usr/bin/slirp4netns is owned by slirp4netns 1.1.9-1
    version: |-
      slirp4netns version 1.1.9
      commit: 4e37ea557562e0d7a64dc636eff156f64927335e
      libslirp: 4.4.0
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.1
  swapFree: 31495360512
  swapTotal: 32211202048
  uptime: 84h 2m 48.15s (Approximately 3.50 days)
registries:
  search:
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  configFile: /home/chigozirim/.config/containers/storage.conf
  containerStore:
    number: 1
    paused: 0
    running: 0
    stopped: 1
  graphDriverName: overlay
  graphOptions:
    overlay.mount_program:
      Executable: /usr/bin/fuse-overlayfs
      Package: /usr/bin/fuse-overlayfs is owned by fuse-overlayfs 1.4.0-1
      Version: |-
        fusermount3 version: 3.10.2
        fuse-overlayfs: version 1.4
        FUSE library version 3.10.2
        using FUSE kernel interface version 7.31
  graphRoot: /home/chigozirim/.local/share/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageStore:
    number: 316
  runRoot: /run/user/1000/containers
  volumePath: /home/chigozirim/.local/share/containers/storage/volumes
version:
  APIVersion: 3.0.0
  Built: 1613921386
  BuiltTime: Sun Feb 21 09:29:46 2021
  GitCommit: c640670e85c4aaaff92741691d6a854a90229d8d
  GoVersion: go1.16
  OsArch: linux/amd64
  Version: 3.0.1


Package info (e.g. output of rpm -q podman or apt list podman):

Name                  : podman
Version               : 3.0.1-2
Description           : Tool and library for running OCI-based containers in pods
URL                   : https://github.com/containers/libpod
Licenses              : Apache
Repository            : community
Installed Size        : 79.3 MB
Depends On            : cni-plugins conmon containers-common device-mapper iptables libseccomp runc slirp4netns libsystemd fuse-overlayfs
                        libgpgme.so=11-64
Optional Dependencies : podman-docker: for Docker-compatible CLI
                        btrfs-progs: support btrfs backend devices [Installed]
                        catatonit: --init flag support
                        crun: support for unified cgroupsv2 [Installed]
Make Dependencies     : btrfs-progs go go-md2man git gpgme systemd
Packager              : Morten Linderud <[email protected]>
Build Date            : 2021-02-21
Install Date          : 2021-02-21
Install Reason        : Explicitly installed
Signatures            : Yes

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide?

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):
This is on my physical machine

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 24, 2021
@rhatdan
Copy link
Member

rhatdan commented Mar 24, 2021

Hopefully you are doing
podman --build-arg "$CFLAGS" --file myDockerFile .

@mheon
Copy link
Member

mheon commented Mar 24, 2021

@rhatdan Didn't you fix this already? I recall writing release notes about this one.

@smac89 Can you try the new RC, v3.1.0-rc2? I'm pretty sure this is fixed.

@rhatdan
Copy link
Member

rhatdan commented Mar 24, 2021

Yes we have had fixes around this, If the first question, came back yes, I was going to suggest they check the new version.

@smac89
Copy link
Author

smac89 commented Mar 24, 2021

Hopefully you are doing
podman --build-arg "$CFLAGS" --file myDockerFile .

Wouldn't this be expanded by the shell before podman gets access to it? So the command ends up looking like:

podman --build-arg "-02 -pipe" --file myDockerFile .

@smac89 Can you try the new RC, v3.1.0-rc2? I'm pretty sure this is fixed.

I haven't tried running a release candidate version. However, when I was looking at the code, I saw:

if c.Flag("build-arg").Changed {
for _, arg := range flags.BuildArg {
av := strings.SplitN(arg, "=", 2)
if len(av) > 1 {
args[av[0]] = av[1]
} else {
// check if the env is set in the local environment and use that value if it is
if val, present := os.LookupEnv(av[0]); present {
args[av[0]] = val
} else {
delete(args, av[0])
}
}
}
}

This led me to believe that it was supposedly being handled correctly, so this issue should not be occurring. But I also assumed this was part of the latest stable version (3.0.1). Apparently not, so I guess I'll wait until the next release, and just work around this issue for now.

@edsantiago
Copy link
Member

Dup of #9571 ?

@rhatdan
Copy link
Member

rhatdan commented Mar 24, 2021

Yup and sadly I fixed it. I wish I remembered where I left my memory.

@rhatdan rhatdan closed this as completed Mar 24, 2021
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

5 participants