podman icon indicating copy to clipboard operation
podman copied to clipboard

Podman play kube container's PATH does not use variables set in Dockerfile / docker build

Open kellen-dunham opened this issue 5 years ago • 8 comments

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

/kind bug

Description

While using an image which has something like ENV PATH="$PATH:/bin/aux" in its Dockerfile, while running as a container the path appears to be set from whatever the host's machine's PATH env variable is at that time. This presents issues when critical binaries are located in /bin/aux. A workaround is to set the PATH to include /bin/aux in the pod yaml file, however this is not required in other systems like docker compose.

Steps to reproduce the issue:

  1. Create a pod.yaml file which has an image that alters the PATH environment variable, ie. k3s is a good example
  2. Run podman play kube pod.yaml

Describe the results you received:

The container's PATH does not include what is defined in the Dockerfile.

Describe the results you expected:

The container's PATH does include what is defined in the Dockerfile.

Additional information you deem important (e.g. issue happens only occasionally):

N/A

Output of podman version:

Version: 3.0.1 API Version: 3.0.0 Go Version: go1.15.2 Built: Wed Dec 31 18:00:00 1969 OS/Arch: linux/amd64

Output of podman info --debug:

host: arch: amd64 buildahVersion: 1.19.4 cgroupManager: systemd cgroupVersion: v1 conmon: package: 'conmon: /usr/libexec/podman/conmon' path: /usr/libexec/podman/conmon version: 'conmon version 2.0.26, commit: ' cpus: 12 distribution: distribution: ubuntu version: "20.04" eventLogger: journald hostname: pc idMappings: gidmap: null uidmap: null kernel: 5.4.0-66-generic linkmode: dynamic memFree: 24119320576 memTotal: 33513377792 ociRuntime: name: crun package: 'crun: /usr/bin/crun' path: /usr/bin/crun version: |- crun version 0.18.1-7931a-dirty commit: 7931a1eab0590eff4041c1f74e2844b297c31cea spec: 1.0.0 +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL os: linux remoteSocket: exists: true path: /run/podman/podman.sock security: apparmorEnabled: true 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 selinuxEnabled: false slirp4netns: executable: "" package: "" version: "" swapFree: 8589930496 swapTotal: 8589930496 uptime: 34m 21.95s registries: search:

  • docker.io
  • quay.io
  • ghcr.io store: configFile: /etc/containers/storage.conf containerStore: number: 35 paused: 0 running: 0 stopped: 35 graphDriverName: overlay graphOptions: overlay.mountopt: nodev,metacopy=on graphRoot: /var/lib/containers/storage graphStatus: Backing Filesystem: extfs Native Overlay Diff: "false" Supports d_type: "true" Using metacopy: "true" imageStore: number: 106 runRoot: /run/containers/storage volumePath: /var/lib/containers/storage/volumes version: APIVersion: 3.0.0 Built: 0 BuiltTime: Wed Dec 31 18:00:00 1969 GitCommit: "" GoVersion: go1.15.2 OsArch: linux/amd64 Version: 3.0.1

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

Listing... Done podman/unknown,now 100:3.0.1-2 amd64 [installed] podman/unknown 100:3.0.1-2 arm64 podman/unknown 100:3.0.1-2 armhf podman/unknown 100:3.0.1-2 s390x

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.):

Physical

kellen-dunham avatar Mar 11 '21 21:03 kellen-dunham

@ashley-cui PTAL

rhatdan avatar Mar 12 '21 11:03 rhatdan

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

github-actions[bot] avatar Apr 12 '21 00:04 github-actions[bot]

I can take a look at this one if it is still open.

EduardoVega avatar Apr 17 '21 17:04 EduardoVega

Thanks @EduardoVega. I haven't had a lot of time to walk through this issue, however I did find that docker uses this function to build out the environment vars ReplaceOrAppendEnvValues on the container:

https://github.com/moby/moby/blob/8eb947c5b1d7ce7551ed6e07db7a8b65234b75e0/container/env.go#L9

Hopefully this helps!

kellen-dunham avatar Apr 17 '21 20:04 kellen-dunham

@EduardoVega It's yours

rhatdan avatar Apr 19 '21 17:04 rhatdan

@kellen-dunham I haven't been able to replicate your issue, so please let me know if I'm missing something here.

Currently I am using fedora with podman version:

Version:      3.1.2
API Version:  3.1.2
Go Version:   go1.14
Git Commit:   51b8ddbc22cf5b10dd76dd9243924aa66ad7db39
Built:        Thu Apr 22 11:23:22 2021
OS/Arch:      linux/amd64
  1. Containerfile / Dockerfile
FROM fedora

ENV PATH="$PATH:/bin/aux"

CMD tail -f /dev/null
  1. Build image
podman build --tag 9700 .
  1. Run container and check $PATH env var
$ podman run --rm 9700 sh -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/bin/aux
  1. pod.yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: watermelon
  name: watermelon
spec:
  containers:
  - command:
    - sh
    args:
    - -c
    - sleep 3600
    image: 9700
    name: ctr01
    securityContext:
      allowPrivilegeEscalation: true
      capabilities:
        drop:
        - CAP_MKNOD
        - CAP_NET_RAW
        - CAP_AUDIT_WRITE
      privileged: false
      readOnlyRootFilesystem: false
  1. Create pod using play kube and check $PATH env var
$ podman play kube pod.yaml
$ podman exec watermelon-ctr01 sh -c 'echo $PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/bin/aux

EduardoVega avatar Apr 22 '21 19:04 EduardoVega

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

github-actions[bot] avatar May 23 '21 00:05 github-actions[bot]

Since we never heard response back from @kellen-dunham I am going to assume this problem went away or is fixed in newer versions of Podman. Please reopen if you have further information and get it to fail on the current code in the main branch.

rhatdan avatar May 24 '21 13:05 rhatdan