Docker保存数据 [英] Docker saving data

查看:113
本文介绍了Docker保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行一个容器,例如,安装vim.我退出了容器.然后,我想重新运行容器,并仍然安装vim.

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.

有没有办法做到这一点,因为每次重新启动容器vim都不会.

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

推荐答案

有没有办法做到这一点,因为每次我重新启动容器时,vim都不存在

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,

$ docker ps -a |grep 9c8e962f21e7
9c8e962f21e7        centos:6    "bash"     6 days ago    Exited (137) 2 seconds ago   boring_stallman

docker exec

一起运行

run with docker exec

docker start 9c8e962f21e7
docker exec -ti 9c8e962f21e7 bash

如果以前安装过vim,则可以登录并运行vim.

You should be fine to login and run vim if you installed it before.

docker attach 9c8e962f21e7

这篇关于Docker保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆