Is it safe to export tarball to a docker container?

I play a couple of days with docker.io. It is excellent! Some simple containers are already running on production servers.

Right now, I am fixated on how to back up the container. Suppose I have launched a complex docker container with a supervisor + apache + memcached + mysql inside under load (10 thousand requests per second). Is it safe to do

docker export> backup.tar

Or do I need to stop all processes inside the container, and only after that export container to the tar file?

+1
docker
Jun 05 '14 at 22:20
source share
1 answer

If by β€œsafe” you mean β€œconsistent,” then the exported archive will be a consistent file system .

The docker export , like any other classic backup method, will not solve the problem of application consistency.

Apache and Memcached will not be a problem, as they do not need storage to maintain any state.

But backing up Mysql in this way is likely to cause the database to reboot in recovery mode if you run the container from an image generated by docker export .

In particular, when backing up while performing a write operation (insert, update ..) as with any other backup at the file system level, you will lose several transactions.

If you need backup Mysql data files that should be 100% compatible and reflect the exact state of your data, you must either:

  • Stop Mysql before starting docker export
  • Stop the entire container
  • Before running the export command, connect to Mysql and run flush tables with read lock; . When the export is complete, you will need to run unlock tables; Files with backup data (usually under / var / lib / mysql) will be consistent.
  • Use classic mysql backup tools ( mysqldump ...)
+2
Jun 08 '14 at 9:30
source share



All Articles