Docker Community Forums

Share and learn in the Docker community.

Exec bash on the last run container

There in web are many examples to rm all containers with xargs,
but when to docker exec, you’ll have a command error like this,

~$ docker ps -lq | xargs docker exec bash
Error response from daemon: No such container: bash

I work around with this, but a error too.

$ docker ps -lq | xargs -I % docker exec -it % bash
the input device is not a TTY

I can do it with this,

$ docker exec -it {ID here} bash

What is wrong?

Try removing the “-t” switch.

I’ve had the same problem while trying to run a container from a systemd service unit file:

Dec 23 18:46:17 XXXXXXX docker[24578]: the input device is not a TTY