在Docker中实现MySQL的灾难恢复可以采取以下步骤:
docker run -d --name mysql-container -e MYSQL_ROOT_PASSWORD=password mysql
docker exec mysql-container mysqldump -u root -p --all-databases > /path/to/backup.sql
docker volume create mysql-data
docker run -d --name mysql-container -e MYSQL_ROOT_PASSWORD=password -v mysql-data:/var/lib/mysql mysql
docker cp /path/to/backup.sql mysql-container:/var/lib/mysql/backup.sql
docker stop mysql-container
docker rm mysql-container
docker run -d --name new-mysql-container -e MYSQL_ROOT_PASSWORD=password -v mysql-data:/var/lib/mysql mysql
docker exec new-mysql-container mysql -u root -p < /var/lib/mysql/backup.sql
通过以上步骤,可以在Docker中实现MySQL的灾难恢复,保证数据库在发生灾难时能够及时恢复。