You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
If we try to attach to a container that has been started as shown below, the following error will occur.
[haytok@lima-finch workspace]$ sudo nerdctl run --name test -d alpine sh -c "while true; do echo /'Hello, world/'; sleep 1; done"
54f605cda9b8184a5d16a543ba482dfaa1a90d3e71d9903c19b667bd202f5b18
[haytok@lima-finch workspace]$ sudo nerdctl ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
54f605cda9b8 docker.io/library/alpine:latest "sh -c while true; d…" 3 seconds ago Up test
[haytok@lima-finch workspace]$ sudo nerdctl attach test
FATA[0000] 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
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.
My understanding is that when a container is launched with -d flag, the stdout and stderr streams will be forwarded to the logging driver, so when you attach to this container there are no output fifos to open. Would probably need to have the output streams directed to both fifos and logging driver to make it work. There is a discussion on #1946 to support this dual logging feature, but looks like there hasn't been much progress.
My understanding is that when a container is launched with -d flag, the stdout and stderr streams will be forwarded to the logging driver, so when you attach to this container there are no output fifos to open. Would probably need to have the output streams directed to both fifos and logging driver to make it work. There is a discussion on #1946 to support this dual logging feature, but looks like there hasn't been much progress.
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.
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.
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.
Activity
Shubhranshu153 commentedon Mar 14, 2024
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.
Shubhranshu153 commentedon Mar 14, 2024
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.
mharwani commentedon Mar 14, 2024
Is this change compatible with
nerdctl logs?My understanding is that when a container is launched with
-dflag, thestdoutandstderrstreams will be forwarded to the logging driver, so when you attach to this container there are no output fifos to open. Would probably need to have the output streams directed to both fifos and logging driver to make it work. There is a discussion on #1946 to support this dual logging feature, but looks like there hasn't been much progress.fahedouch commentedon Mar 14, 2024
This is implemeted here but not yet enabled for detach mode, I will take care of this
Shubhranshu153 commentedon Mar 14, 2024
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.
mharwani commentedon Mar 14, 2024
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.
Shubhranshu153 commentedon Mar 14, 2024
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.
Shubhranshu153 commentedon Mar 20, 2024
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.
fahedouch commentedon Mar 21, 2024
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.
Shubhranshu153 commentedon Mar 21, 2024
yes thats a good suggestion.
Can i get assigned to this one, would like to implement it.