0

"With docker images we can keep both the previous image and the new image on an instance at the same time. Since the previous images are still on the instance, rollbacks are just a matter of restarting the container pointing to the previous image."

Hi I'm new to Docker and am planning to use MySQL with Docker by creating a MySQL image and a data-only container for persistence data. May I know how can I rollback the data in the container (for example I alter the table) after I destroy and recreate the MySQL container?

Hans
  • 451
  • 1
  • 6
  • 20

1 Answers1

0

For persistent data, practically, you have to mount a host directory as a data volume or store your data on cloud storage. Unless you cannot rollback data after you destroy your data container.

To mount a host directory as a data volume.

Either, you let the data-only container mount the host directory or Create new container and use --volumes-from to perform backup.

Check this out: https://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume

zdk
  • 1,528
  • 11
  • 17
  • Thanks! Do I have to create script to rollback the data after I destroy the data container? – Hans Nov 06 '14 at 01:38
  • @Han well, it depends. if you mount mysql data directory as host directory, I don't think you need to do anything. just mount it back when you create new instance. But if the backup directory is exported sql, then you need some sort of script. – zdk Nov 06 '14 at 07:33