Ⅰ问题概述
之前使用docker run [option] [image] bash
生成并且启动一个docker后,进入docker后执行exit
会导致docker不再运行。现在发现只需要多做一步操作就可以避免退出。
Ⅱ方法
① docker run -ti [image name]:[tag name] bash
we will enter the inside of docker after execute the previous command, maybe the name is decided randomly by os, we can distinguish by the start time.
② execute exit
logout form the docker
③ docker rename [old docker name] [new docker name]
we can rename the docker name, in order to locate the docker we work at.
④ docker start [docker name]
this is key step. we can come true our goal that the docker is not to exit after we execute the command of exit.
⑤ docker exec -ti --user root [docker name] bash
enter the docker and work in it.