How to interact with docker and return information, similar to docker exec -it ubuntu /bin/bash
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
import docker
client = docker.DockerClient("tcp://192.168.186.144:2375")
socket = client.containers.get("cb07b0ec35c2").exec_run("/bin/bash", stdin=True, socket=True)
socket._sock.sendall(b"ls / -la\n")
data= socket._sock.recv(1024)
print(data)
try:
unknown_byte = socket._sock.recv(1024)
print(unknown_byte)
while True:
part = socket._sock.recv(1024)
data += part
if len(part) < buffer_size:
break
except Exception:
pass
socket._sock.send(b"exit\n")
It will get stuck after execution。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided DockerClient and exec_run example against a Docker Engine endpoint, focusing on the socket reads after sending ls / -la\n. Compare the behavior with docker exec -it ubuntu /bin/bash; done means interactive command output is received and the session can exit without hanging.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100