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: add --env-file to exec #413

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

vbatts
Copy link
Contributor

@vbatts vbatts commented Oct 5, 2021

Reference: #215

vbatts@melisma:~$ sudo nerdctl --version
nerdctl version 0.12.0-6-g6ca74e6.m
vbatts@melisma:~$ sudo nerdctl exec -it --env FOO=bar farts sh
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
PWD=/
vbatts@melisma:~$ cat > env.sh
FOO=VAT
vbatts@melisma:~$ sudo nerdctl exec -it --env-file ./env.sh farts sh
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=VAT
PWD=/
vbatts@melisma:~$ cat > env.sh
FOO=bar
Bif=BAZ
vbatts@melisma:~$ sudo nerdctl exec -it --env-file ./env.sh farts sh
Bif=BAZ
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
PWD=/
BAZ

Signed-off-by: Vincent Batts vbatts@hashbangbash.com

&cli.StringSliceFlag{
Name: "env-file",
Usage: "Set environment variables from file",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AkihiroSuda
Copy link
Member

AkihiroSuda commented Oct 5, 2021

Thanks, LGTM except the document.

CI seems dead? https://www.githubstatus.com/

@AkihiroSuda AkihiroSuda added this to the v0.12.2 milestone Oct 5, 2021
@AkihiroSuda AkihiroSuda added the enhancement New feature or request label Oct 5, 2021
@AkihiroSuda AkihiroSuda mentioned this pull request Oct 5, 2021
2 tasks
@vbatts
Copy link
Contributor Author

vbatts commented Oct 5, 2021 via email

README.md Outdated
@@ -480,6 +480,7 @@ Flags:
- :whale: `-d, --detach`: Detached mode: run command in the background
- :whale: `-w, --workdir`: Working directory inside the container
- :whale: `-e, --env`: Set environment variables
- :whale: `--env-file`: Set environment variables from file
- :whale: `--privileged`: Give extended privileges to the command

Unimplemented `docker exec` flags: `--detach-keys`, `--env-file`, `--user`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env-file can be now removed from “Unimplemented” list

Reference: containerd#215

```shell
vbatts@melisma:~$ sudo nerdctl --version
nerdctl version 0.12.0-6-g6ca74e6.m
vbatts@melisma:~$ sudo nerdctl exec -it --env FOO=bar farts sh
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
PWD=/
vbatts@melisma:~$ cat > env.sh
FOO=VAT
vbatts@melisma:~$ sudo nerdctl exec -it --env-file ./env.sh farts sh
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=VAT
PWD=/
vbatts@melisma:~$ cat > env.sh
FOO=bar
Bif=BAZ
vbatts@melisma:~$ sudo nerdctl exec -it --env-file ./env.sh farts sh
Bif=BAZ
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
FOO=bar
PWD=/
BAZ
```

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
@vbatts
Copy link
Contributor Author

vbatts commented Oct 5, 2021 via email

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@AkihiroSuda AkihiroSuda merged commit ae1f2d1 into containerd:master Oct 6, 2021
@vbatts vbatts deleted the exec-env-file branch October 6, 2021 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request impact/major
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants