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

Add options to runsc spec command #2554

Open
ianlewis opened this issue Apr 27, 2020 · 1 comment
Open

Add options to runsc spec command #2554

ianlewis opened this issue Apr 27, 2020 · 1 comment

Comments

@ianlewis
Copy link
Contributor

@ianlewis ianlewis commented Apr 27, 2020

Some documentation could be improved by adding some options to runsc spec to allow users to specify the command and some other common OCI options. This could also improve the getting started experience for folks who are kicking the tires with runsc.

I'm thinking of the following options:

  • Option to specify the command
  • Option to specify working directory
  • Option to specify network namespace path
@geethanjalieswaran
Copy link
Contributor

@geethanjalieswaran geethanjalieswaran commented May 14, 2020

I was wondering if I could work on this issue?

At first, I am planning to include the options mentioned above. Maybe later will extend it to other OCI options.

@mikaelmello mikaelmello mentioned this issue May 24, 2020
3 of 5 tasks complete
geethanjalieswaran added a commit to geethanjalieswaran/gvisor that referenced this issue May 25, 2020
copybara-service bot pushed a commit that referenced this issue May 29, 2020
This adds the `cwd` option to the `run spec` command, as asked in #2554.

Since this option is simple and straightforward, I only added a simple formatting rule when retrieving the spec template. I do realize this is not "maintainable" as we add more options, so there are some points that I'd like to raise:

1. I didn't see a lot of tests for cmd files, should I add one for the spec file? If so, any kind of template or good practices I should follow?
2. Other options asked in #2554 are a little more complex since the difference between the default and specified options aren't trivial. I was thinking of creating a full struct specification for OCI configuration files (following [this](https://github.com/opencontainers/runtime-spec/blob/master/config.md)). Any opinions on that matter?

* [x] Have you followed the guidelines in [CONTRIBUTING.md](../blob/master/CONTRIBUTING.md)?
* [x] Have you formatted and linted your code?
* [ ] Have you added relevant tests?
* [x] Have you added appropriate Fixes & Updates references?
* [ ] If yes, please erase all these lines!

---

## Results

```
$ runsc spec --help
spec [options] - create a new OCI bundle specification file.

The spec command creates a new specification file (config.json) for a new OCI bundle.

The specification file is a starter file that runs the "sh" command in the container. You
should edit the file to suit your needs. You can find out more about the format of the
specification file by visiting the OCI runtime spec repository:
https://github.com/opencontainers/runtime-spec/

EXAMPLE:
    $ mkdir -p bundle/rootfs
    $ cd bundle
    $ runsc spec
    $ docker export $(docker create hello-world) | tar -xf - -C rootfs
    $ sed -i 's;"sh";"/hello";' config.json
    $ sudo runsc run hello

  -bundle string
    	path to the root of the OCI bundle (default ".")
  -cwd string
    	working directory that will be set for the executable, this value MUST be an absolute path (default "/")
```

```
$ runsc spec -cwd "/custom/dir"
$ cat config.json
{
	"ociVersion": "1.0.0",
	"process": {
		"terminal": true,
		"user": {
			"uid": 0,
			"gid": 0
		},
		"args": [
			"sh"
		],
		"env": [
			"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
			"TERM=xterm"
		],
		"cwd": "/custom/dir",
		"capabilities": {
[...]
```

FUTURE_COPYBARA_INTEGRATE_REVIEW=#2767 from mikaelmello:add-cwd-option-spec 9e8000e
PiperOrigin-RevId: 313815101
@copybara-service copybara-service bot mentioned this issue May 29, 2020
3 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.