When we created the docker container using command,
$ sudo docker create ubuntu:18.04
and then tried to access the shell as,
$ sudo docker exec -i -t 49db5136dac8 bash
we got an error as,
Error response from daemon: Container 4285cb789189ea8feed154af78a4d736c828b0d149c535fc73b24a44411e8dca is not running
This error is because, when we create the docker container, this container is not running by default, and is in exited state as can be seen below,
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
49db5136dac8 ubuntu:18.04 "/bin/bash" 2 minutes ago Exited (0) 2 minutes ago dazzling_hawking
Solution :
the solution to this problem is we need to run the container in background using IMAGE ID as,
$ sudo docker run -it -d "ubuntu:18.04"