pipeline in docker exec from command line and from python api
You are almost there, you just need to add the -i flag to make the pipe work:
-i, --interactive Keep STDIN open even if not attacheddocker exec -i container-name mysqldump [options] database > database.sql.xz
I replaced the pipe by a file redirection but it will work the same with a Pipe. Just make sure to don't use the -t option as this will break it.
Extra:
To import back the sql dump into mysql:
docker exec -i container-name mysql [options] database < database.sql.xz
This little script will detect if I am running mysql in a pipe or not:
#!/bin/bashif [ -t 0 ]; then docker exec -it container-name mysql "$@"else docker exec -i container-name mysql "$@"fi