How can I keep a docker debian container open?

Posted on Sep 30, 2022

Question

I want to use a debian Docker container to test something, and by this I mean execute some commands in the debian bash console. I tried downloading the image using docker pull debian and then running it using docker run debian, but I get no output. What am I doing wrong? Shouldn't the docker container stay open until I close it?

Answer

You need to explicitly run bash:

docker run -it debian /bin/bash

The -i means "run interactively", and -t means "allocate a pseudo-tty".

A good place to read a bit more is the section Running an interactive shell in the Quickstart documentation.