Skip to content

Add a --with-env flag to limactl shell #3430

@jandubois

Description

@jandubois

Lima tries to create the illusion that containers are running locally by mounting directories and forwarding ports. But there is no mechanism to propagate environment variables to commands executed within the VM.

This is especially needed for nerdctl which cannot run on the host but must be executed inside the VM (see #412).

I propose to add a --with-env feature to limactl shell to pass along all environment variables explicitly on the commandline. Running nerdctl -e FOO ... will then become

limactl shell default FOO=foo … nerdctl -e FOO ...

We will have an internal block list that will exclude a set of variables, like PATH, SSH_* etc.

The user can specify their own blocklist instead:

export LIMA_SHELLENV_BLOCK="PATH,SSH_*"

Exact syntax TBD, but I think it can be simply a list of names, with a * as a wildcard. I don't think we need full regex syntax, but could change my mind if somebody shows a real usecase that can't be done with a simpler form.

If the blocklist starts with a + it will be added to the builtin block list; otherwise it will replace it.

Alternatively the user can specify LIMA_SHELLENV_ALLOW which enumerates all allowed env variables instead (maybe no wildcards allowed?).

The builtin block list will be included in the limactl info output.

nerdctl.lima will become limactl shell --with-env default nerdctl "$@".

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/clilimactl CLI user experienceenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions