Lxc-attach with --param

I need to run something like mysqldump --xxx inside lxc, but looks like lxc daemon assumes that --xxx is lxc-attach param. How to avoid it? I tried doublequtes, bu it didn’t help.

lxc-attach -n myct – mysqldump --quick

lxc-attach -n NAME – command --arg

This should have worked fine, not sure why it didn’t for you, what’s the error?


Based on what is commented here an en dash ( ) was used to indicate the end of lxc-attach parameters. That obviously won’t work. The conventions is to use -- instead, so:

lxc-attach -n myct -- mysqldump --quick

sorry for misunderstanding, it was about redirection:
lxc-attach -n myct echo “qaz” > /var/tmp/qqq/1.txt
bash: /var/tmp/qqq/1.txt: No such file or directory

this path /var/tmp/qqq/ exists inside container only, but applied to host, so there is the error.
how to use redirection in lxc-attach command?

You’d need to do something like lxc-attach -n myct -- sh -c "echo 'qaz' > /var/tmp/qqq/1.txt"