-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Ability to share bash env variables #92
Comments
Possibly related to lima-vm/lima#412 - Using --env for nerdctl doesn't pass through current environment values tl;dr - the nerdctl (cli for containerd runtime) implementation of lima doesn't appear to pass env variables into the VM properly, might be the same situation here? |
Is this with regards to docker or containerd runtime? Or you simply want to have some env vars available in the VM. |
This is with docker runtime. I have a few environment variables that show up when I switch to my project directory (thanks to https://direnv.net/) Is there a way to pass these to the VM. Idea is to be able to use env vars in docker commands. EXAMPLE_VALUE is an environment variable in my host machine. |
@mrsauravsahu if you are using docker runtime, the docker client is on your host machine so this should work already.
as long as |
If you simply want some env vars to be available in the VM, there is an undocumented
This will make those env vars available in the VM and you can verify with NoteDocker and containerd runtime are different in this regard as the docker client runs on the host, but the containerd client (nerdctl) runs in the VM. DockerFor docker runtime, you most likely do not need this except you intend to use the VM directly for other purposes. Your env vars get passed as expected because the client is on your host. ContainerdYou can use the (VM) env vars for containerd runtime by escaping it or use single quote so it doesn't get translated in your current shell but passed down to the VM's shell. nerdctl run --rm -it --env SAMPLE_VAR=\$EXAMPLE_VALUE alpine # this works
nerdctl run --rm -it --env 'SAMPLE_VAR=$EXAMPLE_VALUE' alpine # this works
nerdctl run --rm -it --env SAMPLE_VAR=$EXAMPLE_VALUE alpine # this does not work Next stepsThis can be revisited ahead of next release if there is enough interest. |
Thanks @abiosoft I was facing this issue in containerd, I switched to docker recently. Works great. Thanks. Feel free to keep the thread going for containerd runtime. |
@abiosoft So passing |
Is there a way to pass ENV variables from the shell to the VM?
The text was updated successfully, but these errors were encountered: