Is there a way to do this, because every time I restart a container vim is never there
They are still there. when you run
docker ps -a
You should see all of them, some of them are not in running status, but in exited status.
There are two ways to re-use the same container. For example,
List all containers with docker ps -a
$ docker ps -a |grep 9c8e962f21e7
9c8e962f21e7 centos:6 "bash" 6 days ago Exited (137) 2 seconds ago boring_stallman
run with docker exec
docker start 9c8e962f21e7
docker exec -ti 9c8e962f21e7 bash
You should be fine to login and run vim if you installed it before.
run with docker attach
, if the container start with bash
docker attach 9c8e962f21e7
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…