持久的docker容器 [英] Persistent docker container

查看:110
本文介绍了持久的docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,

我知道我还在做错事,希望你能在这里找到正确的解决方案。

I know that I am still doing something wrong, hopefully here you can point me to the right solution.

使用docker镜像在Azure上部署了一个Container实例。它在3分钟内启动并运行;都好。然后我可以(通过Azure门户)连接到shell并更改配置。

Have deployed a Container Instance on Azure using a docker image. It is up and running within 3 minutes; all good. I can then (via the Azure portal) connect to the shell and change configuration.

但是当我重新启动容器(Azure shell上的az容器重新启动)时,容器被重新启动,所有内容重启。在事件中我也看到从Docker加载了一个新图像。

But when I restart the container (az container restart on the Azure shell) the container is restaged, all content reset. In the Events I also see that a fresh image has been loaded from Docker.

我该如何防止这种情况?如何在docker镜像中拥有持久性数据/配置?

How can I prevent this? How can I have persistent data / configuration within a docker image?

推荐答案

在容器重启时,我们创建的所有文件都将被删除。这是按照设计发生的。

On container restart, all the files which we created will be wiped off. Thats happening as per the design.

因此,每当容器出现时,我们都确信它会提供相同的配置,代码和库。

So that every time when a container comes up, we are sure that its coming up with the same configuration, code and libraries.

如果我们想要保留一些数据,比如日志文件,那么我们需要将一个外部文件系统附加到容器中。 

If we want to persist some data like logs files, Then we need to attach an external file system to the container. 

请按照
文档
共享到容器。

每当容器以Azure文件共享开头时 配置后,Container将该文件共享作为该容器中的目录。然后容器可以利用该空间来存储持久性东西。当容器关闭时,该文件共享
已卸载,保持其上的内容不变。

Whenever a container starts with the Azure file share  configured, Container gets that file share as a directory in that container. Then the container can utilize that space for storing the persistent stuff. When the container goes down, That file share is unmounted, Leaving the content on it untouched.

试试这个并让我知道。


这篇关于持久的docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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