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
failed to attach to the container: failed to open stdout fifo: error creating fifo binary:///usr/local/bin/nerdctl?_NERDCTL_INTERNAL_LOGGING=%2Fvar%2Flib%2Fnerdctl%2F1935db59: no such file or directory
#2877
Comments
It seems
https://github.com/containerd/containerd/blob/main/cmd/ctr/commands/tasks/exec.go which makes the following case invalid
tried to
now it didnt throw errors but i didnt see any stdout. so not sure, but most likely i am not setting it up correctly. |
i think i was able to make it work
the change is
need to clean up these logic a bit and i dont exactly know if this is the correct ioCreator config, but seems to work as expected. |
Is this change compatible with My understanding is that when a container is launched with |
This is implemeted here but not yet enabled for detach mode, I will take care of this |
that may not directly work the stdout binary seems to forward containers stdio to the logging binary, but in detached mode i presume containers stdio is closed? calling the modified function atleast didnt print anything with nerdctl logs but attach worked. |
Yeah, I'm wondering what the best approach is here. We need to keep a process alive to copy buffers from container fifos to a pipe used by logging. Or the logging driver can be restructured to access fifos directly. |
one approach can be to override the attach to pipe the logging. So when we attach we can read directly from the logdriver and print the output as you said. didnt understand the logging driver can be restructured part. |
It seems we run /usr/local/bin/nerdctl _NERDCTL_INTERNAL_LOGGING /var/lib/nerdctl/1935db59 as part of nerdctl child process. In case when nerdctl cli launching container as fg via containerd, it has a wait for the container to exit for the main process to exit. As a result the logging child process doesnt exist. But in a detached mode the nerdctl cli will exit without waiting for the container to exit, as a result the logging cli would also exit. If we pass in the logging uri containerd-shim handles the process (i am not completely sure but it appears so), as a result even if nerdctl cli exits the logging process keeps running. The same dual logging approach we have for non-detached mode may not be viable here and we might need to come up with an alternate solution. Let me know your opinion. |
agree. Apparently, the current architecture of containerd-shim does not allow it to be attached. I think we need to extend the responsibilities of the shim to fifo the stds and therefore when we want to attach, we will connect to this pipe. |
yes thats a good suggestion. |
Discussed in #2876
Originally posted by haytok March 13, 2024
Question
If we try to attach to a container that has been started as shown below, the following error will occur.
Is this the expected behavior?
There seems to be an error in the following part of nerdctl, but I'm in trouble because I don't know how to fix it.
nerdctl/pkg/cioutil/container_io_unix.go
Line 122 in 9ce158b
Note that Docker doesn't cause such an error, and we can attach it to a container.
Environments
I'm using the following versions of containerd and nerdctl.
[haytok@lima-finch workspace]$ containerd --version containerd github.com/containerd/containerd v1.7.13 7c3aca7a610df76212171d200ca3811ff6096eb8 [haytok@lima-finch workspace]$ nerdctl version WARN[0000] failed to inspect the rootless containerd socket address error="stat /run/user/504/containerd-rootless: no such file or directory" Client: Version: v1.7.3 OS/Arch: linux/amd64 Git commit: 0a464409d0178e16d3d2bed36222937ec3fc9c77 buildctl: Version: v0.12.5 GitCommit: bac3f2b673f3f9d33e79046008e7a38e856b3dc6
Note that containerd and nerdctl are running in Lima launched from Finch.
The text was updated successfully, but these errors were encountered: