docker / docker/docker-py

How to get writable io socket when execute exec_start method

Open
#2,744 5 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, guys.
Below is my code snippet:

cid = "cec5e731c0ac"
cmd_info="/bin/bash"
client = docker.APIClient(base_url="tcp://127.0.0.1:2377")
eid = client.exec_create(cid, cmd=cmd_info, privileged=True)
soc_ret = client.exec_start(exec_id=eid, socket=True)
soc_ret.write(b'echo hello world')
client.close()

However, the error io.UnsupportedOperation: File or stream is not writable. occured when executing the code snippet.
So I want to know if there is way to get a writable socket using the exec_start method.

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 at the docker.APIClient.exec_create and exec_start entry points shown in the report, then inspect the library's socket handling and API documentation. Clarify whether the socket returned by exec_start(socket=True) supports writes and document the supported way to interact with it, if one exists.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.