Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I run a container and, say, install vim. I exit out of the container. I would then like to re-run the container and have still have vim installed.

Is there a way to do this, because every time I restart a container vim is never there.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
196 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...