containerd / nerdctl

contaiNERD CTL - Docker-compatible CLI for containerd, with support for Compose, Rootless, eStargz, OCIcrypt, IPFS, ...
Apache License 2.0
8.07k stars 597 forks source link

Using a custom exe for logging in refactored `container create` #2264

Open mharwani opened 1 year ago

mharwani commented 1 year ago

Description

Hey, it's my first post here! 👋

Thank you for refactoring nerdctl #1680. I'm looking at the refactored Create method and I don't see a way to generate the logger URI with nerdctl exe or a custom binary. The method calls GenerateLogURI, 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 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

AkihiroSuda commented 1 year ago

cc @fahedouch

fahedouch commented 1 year ago

Hi @mharwani,

We started a WIP ticket to enhance a list of logging drivers . We planned to handle the local driver as a separate binary, I started working on it some time ago but didn't have time to go further and of course PR is welcome :)