I am trying to do a more complicated task inside a running lxc ubuntu container, but my problem can be explained using this simple example. When I run
sudo lxc-attach -n container1 -- echo "test" > test.txt
inside of a shell script, I expect to find test.txt
inside of my container, but instead I find it on my host machine! What has gone wrong?
sudo lxc-attach -n container1 -- 'echo "test" > test.txt'
?>
. It createstest.txt
(or empties it, if it exists), and only then does it launch thesudo
command, whose output it connects totest.txt
.