Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

boot2docker - Docker saving data

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

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

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...