containerd / containerd/nerdctl
Using a custom exe for logging in refactored `container create`
- Dominant language
- Go
- Stars
- 10.4k
- Forks
- 826
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 44
Description
### Description
Hey, it's my first post here! 👋
Thank you for refactoring nerdctl #1680. I'm looking at the refactored [`Create`](https://github.com/containerd/nerdctl/blob/02ad937ea59abcf01f210b16af061386a2d87d0e/pkg/cmd/container/create.go#L60) method and I don't see a way to generate the logger URI with nerdctl exe or a custom binary. The method calls [`GenerateLogURI`](https://github.com/containerd/nerdctl/blob/02ad937ea59abcf01f210b16af061386a2d87d0e/pkg/cmd/container/create.go#L406), which will use the exe of the calling function during runtime. However, an external program may still want to use the nerdctl exe for logging instead, or specify a custom binary location.
```
// GenerateLogURI generates a log URI for the current container store
func GenerateLogURI(dataStore string) (*url.URL, error) {
selfExe, err := os.Executable()
if err != nil {
return nil, err
}
args := map[string]string{
logging.MagicArgv1: dataStore,
}
return cio.LogURIGenerator("binary", selfExe, args)
}
```
Perhaps we could use the existing [`NerdctlCmd`](https://github.com/containerd/nerdctl/blob/02ad937ea59abcf01f210b16af061386a2d87d0e/pkg/api/types/container_types.go#L51) option that is used for oci-hooks, or define a new option such as `LoggerExe` in `ContainerCreateOptions`? Please let me know your thoughts. I'm happy to work on this myself and create a PR!
### Steps to reproduce the issue
_No response_
### Describe the results you received and expected
External programs calling the `Create` method should be able to use nerdctl exe or a custom binary for logging.
### What version of nerdctl are you using?
v1.4.0
### Are you using a variant of nerdctl? (e.g., Rancher Desktop)
None
### Host information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.