0

Send stdin into docker container in docker-py

stdin type string

In container, there is a a.py file in /app

print(input())

In out of container, I use:

import docker
client = docker.from_env()
container  = client.containers.run("input_t", detach = True);

print(container.exec_run("python a.py").output.decode())

container.stop()
container.remove()

to run the python file in it.

I has no idea with how send stdin inside container.

What I try:

1.from gpt

print(container.exec_run("python a.py",stdin = "1".encode()).output.decode())

2.search the officail document, there has no clear description of this problem

0 Answers0