-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
[BUG] docker exec
not printing any output under socket-proxy
#10
Comments
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid. |
So from very quick testing it looks like you need to exec with $ DOCKER_HOST=tcp://localhost:2378 docker exec healthchecks ps
$ DOCKER_HOST=tcp://localhost:2378 docker exec -i healthchecks ps
PID TTY TIME CMD
1 ? 00:00:00 s6-svscan
16 ? 00:00:00 s6-supervise
20 ? 00:00:00 s6-linux-init-s
61 ? 00:00:00 s6-supervise
62 ? 00:00:00 s6-supervise
63 ? 00:00:00 s6-supervise
64 ? 00:00:00 s6-supervise
72 ? 00:00:00 s6-ipcserverd
185 ? 00:00:00 busybox
1320 ? 00:00:00 ps |
Oh yeah that works! Although, in my opinion this should still be considered a socket-proxy bug since you don't have to specify |
I'm not sure, I'd have to dig into exactly what's going on; I know docker exec is using websockets under the hood but I'm not sure exactly how it interacts with the http API. |
@thespad If it helps, I have sniffed the HTTP traffic of both the As you can see the main differences are that the Edit: Tried it again. Same result. |
Not sure we can reasonably modify the way it interoperates with nginx there. Are you in a position to test against the tcp docker endpoint rather than the socket? It shouldn't be an different in theory but it might be. |
I did actually do this already, I think. Here is how I sniffed the traffic:
Let me know if you need any help getting this to work on your machine. |
While writing the last comment I have noticed that the Docker daemon actually logs an error when I run ERROR[2024-07-03T03:51:35.941330603+02:00] Error running exec ef98aa56fc85a013ba3bf55f20a891c1968101dddd350bc95ef4291ba230bd58 in container: exec attach failed: error attaching stdout stream: write unix /var/run/docker.sock->@: write: broken pipe This is definitely the source of the problem! The same error is logged on my server. Why it only happens for socket-proxy and not the direct TCP/Socket endpoint? I don't know... I will check if Tecnativa/docker-socket-proxy has the same problem... EDIT: It works with Tecnativa's docker-socket-proxy. I'll try to find out what they do differently... EDIT 2: Here is the Docker daemon log leading up to the error above, with debug log enabled: DEBU[2024-07-03T05:07:03.950660279+02:00] Calling HEAD /_ping
DEBU[2024-07-03T05:07:03.951248332+02:00] Calling GET /v1.46/containers/socket-proxy/json
DEBU[2024-07-03T05:07:03.952955791+02:00] Calling POST /v1.46/containers/socket-proxy/exec
DEBU[2024-07-03T05:07:03.953028291+02:00] form data: {"AttachStderr":true,"AttachStdin":false,"AttachStdout":true,"Cmd":["echo","Hi"],"Detach":false,"DetachKeys":"","Env":null,"Privileged":false,"Tty":false,"User":"","WorkingDir":""}
DEBU[2024-07-03T05:07:03.954046261+02:00] Calling POST /v1.46/exec/3aaa192d3a940508cc7cb665ae5c4ed65794929364887c58671ce231bd4d4068/start
DEBU[2024-07-03T05:07:03.954093599+02:00] form data: {"Detach":false,"Tty":false}
DEBU[2024-07-03T05:07:03.954201937+02:00] starting exec command 3aaa192d3a940508cc7cb665ae5c4ed65794929364887c58671ce231bd4d4068 in container 701651b0afdcc068edcf4286ce66087072195672a19a31771845d2cd7f2d262f
DEBU[2024-07-03T05:07:03.955190819+02:00] Calling GET /v1.46/exec/3aaa192d3a940508cc7cb665ae5c4ed65794929364887c58671ce231bd4d4068/json
DEBU[2024-07-03T05:07:03.956104406+02:00] attach: stdout: begin
DEBU[2024-07-03T05:07:03.956112521+02:00] attach: stderr: begin
DEBU[2024-07-03T05:07:03.957266663+02:00] event module=libcontainerd namespace=moby topic=/tasks/exec-added
DEBU[2024-07-03T05:07:03.996514541+02:00] attach: stdout error="write unix /var/run/docker.sock->@: write: broken pipe"
DEBU[2024-07-03T05:07:03.996608812+02:00] attach: stdout: end
DEBU[2024-07-03T05:07:03.996915904+02:00] event module=libcontainerd namespace=moby topic=/tasks/exec-started
DEBU[2024-07-03T05:07:03.996966565+02:00] event module=libcontainerd namespace=moby topic=/tasks/exit
DEBU[2024-07-03T05:07:03.997014714+02:00] attach: stderr: end
DEBU[2024-07-03T05:07:03.997041415+02:00] attach done
ERRO[2024-07-03T05:07:03.997104052+02:00] Error running exec 3aaa192d3a940508cc7cb665ae5c4ed65794929364887c58671ce231bd4d4068 in container: exec attach failed: error attaching stdout stream: write unix /var/run/docker.sock->@: write: broken pipe And here is what gets logged when doing the same thing with Tecnativa's docker-socket-proxy:
Here is a comparison between the two: https://www.diffchecker.com/Va1xo5Mp/ EDIT 3: I have added some info from the comments to the original issue above. This could help anyone else stumbling across this issue. |
This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions. |
Not stale. |
I believe this is entirely unrelated but for some reason |
It is related. it matches the findings regarding the hijack. |
Is there an existing issue for this?
Current Behavior
For some reason when using the
docker exec
command with the proxy I don't get any output back. This only happens when I use linuxserver/socket-proxy:I have enabled literally every possible endpoint permission in the
socket-proxy-exec
container, so I don't think I'm missing something there.EDIT 1: It does work as expected when passing the
--interactive
argument todocker exec
:But you shouldn't have to do that. After all Tecnativa's docker-socket-proxy doesn't require it.
EDIT 2: After sniffing the HTTP traffic the only noticable difference between the direct connection to Docker / Tecnativa's docker-socket-proxy and linuxserver's socket-proxy is that in the response from
GET /v1.46/exec/{id}/json
the fieldsRunning
andExitCode
are different:The reason is unknown. Presumably because the STDOUT pipe fails to open? See Docker daemon logs below.
EDIT 5: It seems like there is now a similar problem with the latest version of Tecnativa's docker-socket-proxy: Tecnativa/docker-socket-proxy#132
According to @Roxedus it is related to this issue, since it matches the findings regarding the hijack.
Expected Behavior
Steps To Reproduce
docker exec
using the socket-proxy:docker exec
WITHOUT using the socket-proxy:Environment
Docker creation
Container logs
EDIT 4: Docker daemon logs
The text was updated successfully, but these errors were encountered: