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

nerdctl - environment variables not passed from host to container (-e) #1279

Open
MatthewJSalerno opened this issue Jan 19, 2022 · 3 comments
Assignees
Labels
area/preferences component/lima Issues related to lima and qemu kind/bug Something isn't working platform/macos
Milestone

Comments

@MatthewJSalerno
Copy link

MatthewJSalerno commented Jan 19, 2022

Rancher Desktop Version

0.7.1

Rancher Desktop K8s Version

1.23.1

What operating system are you using?

macOS

Operating System / Build Version

macOS Big Sur 11.6.2

What CPU architecture are you using?

x64

Linux only: what package format did you use to install Rancher Desktop?

No response

Windows User Only

No response

Actual Behavior

When running a container with nerdctl, the environment variables are not passed to the container unless the value is explicitly defied in the run command.

nerdctl run -ti -e FOO=bar alpine env

  • Will print the FOO variable

% export BAR=foo
% nerdctl run -ti -e BAR alpine env

  • Will not print the BAR variable even though it is being set on the host.

I have tried on debian as well and received the same result.

Steps to Reproduce

% export BAR=foo
% nerdctl run -ti -e BAR -e FOO=bar alpine env

Result

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
TERM=xterm
HOME=/root

Expected Behavior

The expected behavior is that the env set on the host (BAR) would be passed to the container by specifying "-e BAR" in the run command.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
BAR=foo
FOO=bar
TERM=xterm
HOME=/root

Additional Information

Possibly related to #1267 but the main focus on that issue is related to proxies.

@MatthewJSalerno MatthewJSalerno added the kind/bug Something isn't working label Jan 19, 2022
@evertonlperes
Copy link
Contributor

evertonlperes commented Jan 19, 2022

Just replicated the issue and it seems similar to lima-vm/lima#412
Using containerd:

❯ nerdctl run -it --env BAR --env FOO=bar alpine env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
TERM=xterm
HOME=/root
❯ nerdctl run -it --env BAR --env FOO=bar alpine env
❯ export VERTO=test

❯ nerdctl run -it --env VERTO --env FOO=bar alpine env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
TERM=xterm
HOME=/root

❯ nerdctl run -it --env $VERTO --env FOO=bar alpine env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
TERM=xterm
HOME=/root

Using moby (dockerd) container runtime, works as expected:

❯ docker run -it --env BAR --env FOO=bar alpine env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=827ccd1f8a61
TERM=xterm
BAR=foo
FOO=bar
HOME=/root

RD version: 1.0.0-beta1
OS: macOS Monterey 12.1 - amd64

@gaktive gaktive added the component/lima Issues related to lima and qemu label Jan 24, 2022
@gaktive gaktive added this to the v1.0.1 milestone Jan 24, 2022
@gaktive gaktive modified the milestones: Next, Later Feb 15, 2022
@gaktive gaktive modified the milestones: Later, Next Feb 22, 2022
@gaktive gaktive modified the milestones: Next, Later Mar 15, 2022
@gunamata gunamata modified the milestones: Next, Later Apr 12, 2022
@gaktive gaktive modified the milestones: Next, Later May 17, 2022
@jandubois jandubois modified the milestones: Next, Later Jul 14, 2022
@gaktive gaktive modified the milestones: Next, Later Aug 16, 2022
@bhavanki
Copy link

This may be fixed when Rancher Desktop ships with nerdctl >= 1.1.0:

containerd/nerdctl#1524

@jandubois
Copy link
Member

@bhavanki That is a different issue. The problem for Rancher Desktop is that nerdctl has to run inside the VM to have access to the image layer storage. That means it doesn't see the environment variables defined in the shell on macOS.

The nerdctl issue would be referring to the VM as the host, as opposed to the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/preferences component/lima Issues related to lima and qemu kind/bug Something isn't working platform/macos
Projects
None yet
Development

No branches or pull requests

6 participants