docker / docker/docker-py

'NpipeSocket' object has no attribute '_sock'

Open
#2,524 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

Hi!

I'm trying to send commands to the stdin of a container. On Linux, I can do this sending to the _sock like this.

container = self._docker_client.containers.get(test)

s = container.attach_socket(params={"stdin": 1, "stream": 1})
s._sock.send(f"{command}\n".encode("utf-8"))
s.close()

But, when I try to do this on Windows I get the following exception.

AttributeError: 'NpipeSocket' object has no attribute '_sock'

Is there any equivalent way of getting _sock on the Windows socket?

If you want some context, this is where I'd like to use it: https://github.com/wilfred-dev/wilfred/blob/22c38862f162cb5c586df4f3de8d447cdddcf24a/wilfred/servers.py#L286

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the attach_socket API and the NpipeSocket object mentioned in the report, then compare their Windows and Linux behavior. Check whether the project has tests covering socket attachment on Windows. Done means establishing and documenting a supported way to send stdin commands on Windows, or clearly documenting the limitation if none exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.