Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of backing up container data in docker

Shulou Source: shulou.com Published: 2022-06-03 05:42:42 09月21日 Update

What are the ways to back up container data in docker? Docker can use volume storage (Volume) to persist and back up files in the host. Volumes are stored in part of the host file system managed by Docker (/ var/lib/docker/volumes/ on Linux).

Container backup data volume

1. Create a data volume named dbvolume and mount it in the / dbdate directory called dbstore container.

Docker run-d-name dbstore-v dbvolume:/dbdata alpine sh

two。 Write data to a dbvolume volume

[root@node2 ~] # docker exec-it dbstore sh/ # echo hello > / dbdata/test.txt/ # exit

3. Back up the data volumes in the container

[root@node2] # docker run-- rm-- volumes-from dbstore-v $(pwd): / backup alpine tar cvf / backup/backup.tar / dbdatatar: removing leading'/ 'from member namesdbdata/dbdata/test.txt

This is the end of the method of backing up container data in docker. I hope the above content can be of some reference value and can be put into practice. If you like this article, you might as well share it for more people to see.

Tags: Data backup container storage method file learning for application host value content host host article more directory system reference management Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Technology OPPO Reno vpn MariaDB