简体   繁体   English

Docker-重新创建后在MySQL容器中回滚数据

[英]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." “使用docker映像,我们可以同时在一个实例上保留先前的映像和新映像。由于先前的映像仍在该实例上,因此回滚只是重新启动指向先前映像的容器即可。”

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. 嗨,我是Docker的新手,并计划通过创建MySQL映像和持久性数据的仅数据容器来将MySQL与Docker结合使用。 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? 我可以知道销毁并重新创建MySQL容器后如何回滚容器中的数据(例如,更改表)吗?

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. 您要么让仅数据的容器挂载主机目录,要么让它创建新容器并使用--volumes-from进行备份。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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