dockerpty icon indicating copy to clipboard operation
dockerpty copied to clipboard

Dockerpty not compatible with docker version 3.0.0

Open falu2010 opened this issue 7 years ago • 2 comments

Looks like dockerpty is not compatible with docker version 3.0.0.

falu2010 avatar Feb 02 '18 00:02 falu2010

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)

vanpelt avatar Feb 17 '19 19:02 vanpelt

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)

lacek avatar Jun 04 '19 05:06 lacek