Lxd: Appending text to file inside a container does not create file (lxc exec container -- "echo test > file.sh")

Created on 22 Jan 2017  路  1Comment  路  Source: lxc/lxd

The below code does not create a file inside the container.

lxc launch ubuntu: test
lxc exec test -- "echo test > /home/ubuntu/file.sh"
lxc exec test -- ls /home/ubuntu

Most helpful comment

That's because there is no command called "echo test > /home/ubuntu/file.sh" in your container.

I suspect you want:

lxc exec test -- sh -c "echo test > /home/ubuntu/file.sh"

>All comments

That's because there is no command called "echo test > /home/ubuntu/file.sh" in your container.

I suspect you want:

lxc exec test -- sh -c "echo test > /home/ubuntu/file.sh"
Was this page helpful?
0 / 5 - 0 ratings