简体   繁体   中英

Docker - Rollback data in MySQL container after recreating

"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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM