出口运输码头容器的tarball是否安全? [英] Is it safe to export tarball of running docker container?

查看:159
本文介绍了出口运输码头容器的tarball是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在docker.io玩了几天。太棒了!
一些简单的容器已经在生产服务器中运行。



目前我坚持如何进行容器备份。
假设我已经运行复杂的docker容器与主管+ apache + memcached + mysql里面hi加载(10k请求每秒)。
可以安全地使


docker export> backup.tar


或者我必须停止容器内的所有进程,只有在导出容器到tar文件之后才能停止。

解决方案

如果以安全表示一致,那么导出的档案将是文件系统一致



docker export 命令,作为任何其他经典的备份方法,都不会解决应用程序一致的问题。



Apache和Memcached不会是一个问题,因为他们不需要存储来维护任何状态。



但是,如果从 docker export 生成的映像运行容器,则以这种方式备份Mysql可能会使您的数据库以恢复模式重新启动。



特别是,如果在执行写入活动(insert,updates ..)时备份,
与任何其他文件系统级备份一样,您将会丢失一些事务。 / p>

如果您需要将Mysql备份的数据文件保持100%一致,并反映数据的确切状态,则必须:




  • 在运行停止Mysql之前,停靠整个容器

  • 在运行导出命令之前,连接到Mysql的东西,并运行具有读锁定的flush表; 。导出完成后,您必须运行 unlock tables; 备份的数据文件(通常在/ var / lib / mysql下)将一致。

  • 使用古典的Mysql备份工具( mysqldump ...)


I am playing a couple of days with docker.io. It is awesome! Some simple containers already run in production servers.

At the moment I stuck in how to make container backup. Assume I have running complicated docker container with supervisor+apache+memcached+mysql inside under hi load (10k requests per second). Is it safe to make

docker export > backup.tar

Or I have to stop all processes inside container and only after that export container to tar file?

解决方案

If by "safe" you mean "consistent", then the exported archive will be filesystem consistent.

The docker exportcommand, as any other classical backup method, won't solve the problem of being application consistent.

Apache and Memcached won't be an issue, since they don't need storage to maintain any kind of state.

But backuping Mysql this way will probably make your database restart in recovery mode, if you run a container from the image generated by docker export.

In particular, if backuped when having to perform write activity (insert, updates..), as with any other filesystem-level backup, you will loose a few transactions.

If you need your Mysql backuped datafiles to be 100% consistent and to reflect the exact state of your data, you have to either:

  • Stop Mysql before running docker export
  • Stop the whole container
  • Have something connecting to Mysql before running the export command, and run flush tables with read lock;. When the export completes, you'd have to run unlock tables;The backuped data files (generally under /var/lib/mysql) will be consistent.
  • Use the classical Mysql backup tools (mysqldump...)

这篇关于出口运输码头容器的tarball是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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