How to use xtrabackup to back up mysql data in docker container?

Such as the title:
How to use xtrabackup to back up mysql data in docker container?

Do you mean from within a Docker container, or to use the docker container as a destination?
In the first instance, this blog might help you. Although it’s about windows, it addresses using Percona XtraBackup in Docker [URL]https://www.percona.com/blog/2017/03/20/running-percona-xtrabackup-windows-docker/[/URL]

If that’s not enough to get you going, feel free to come back with additional details of what you are trying to achieve.

We have some mysqld services that are running in the docker container.
How to use xtrabackup to back up the database in the container.

Hi,

In order to do the backup, we need to find the local directory on the host where the data exists as well as the internal IP that the container is using so the xtrabackup container can reach it. We can do this by using Docker inspect. As you’ll see below, the local source directory is /var/lib/docker/volumes/3704326a0cf27d1ea158be4c0224f53579d2a674642a90349713c1144da85a72/_data and the IP address is 172.17.0.5.

$ sudo docker inspect vinnie_253823
...
"Mounts": [
{
"Type": "volume",
"Name": "3704326a0cf27d1ea158be4c0224f53579d2a674642a90349713c1144da85a72",
"Source": "/var/lib/docker/volumes/3704326a0cf27d1ea158be4c0224f53579d2a674642a90349713c1144da85a72/_data",
"Destination": "/var/lib/mysql",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
...
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "403064a581385aa12a91b0d2f4c318d496b53be9d00752682192dbea93632c41",
"EndpointID": "cf5257be0f558287fe043b19b533699428db465103b73b9235867fb4cb6e82cf",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.5",

Then replace it accordingly on the line below:

sudo docker run --rm -it -v[B] /var/lib/docker/volumes/3704326a0cf27d1ea158be4c0224f53579d2a674642a90349713c1144da85a72/_data[/B]:/var/lib/mysql -v [B]/home/vinicius.grippa/backup[/B]:/xtrabackup_backupfiles perconalab/percona-xtrabackup --backup --host=172.17.0.5 --user=root --password=percona --port 3306

​​​​​​

And the backup will be executed. The xtrabackup container will auto-destroy after completing the task. Don’t forget to change the user and password too.

Ok,thanks.
I will try