Open falu2010 opened 6 years ago
It actually works with 3.0.0, you just need to pass in the low level api to start.
image = "nginx"
dir = "/app"
cwd = os.getcwd()
container = client.api.create_container(
image,
"/bin/sh",
volumes=[dir],
host_config=client.api.create_host_config(
binds={cwd: {"bind": dir, 'mode': 'rw'}}
),
stdin_open=True,
tty=True,
environment={
"LANG": "C.UTF-8"
}
)
dockerpty.start(client.api, container)
It also works with client.containers.create
with a simple replacement of container
by container.id
in the call of start
:
client = docker.from_env()
container = client.containers.create(...)
dockerpty.start(client.api, container.id)
Looks like dockerpty is not compatible with docker version 3.0.0.