Turn out it is the user permission issue. Files in /var/lib/mysql is owned by user 999, and id $(whami) shows the current user is mysql(1001).
To fix this issue I add -u option to the docker run to run bash as user 999:
docker compose run -u 999 mysql_backup bash