Score:0

lxc send file or copy

mq flag

I am trying to copy a file with lxc, now I am already desperate. Here are some commands that I have tried:

#temp=$(cat 2.sh)
#lxc-attach -n containerName echo $temp > /root/2.sh
#lxc-attach -n containerName cat /root/2.sh
->

#temp=$(cat 2.sh)
#lxc-attach -n containerName -- bash -c 'echo $temp > /root/2.sh'
#lxc-attach -n containerName cat /root/2.sh
->

#lxc-attach -n containerName -- bash -c 'echo $(cat 2.sh) > /root/2.sh'
->cat: 2.sh: No such file or directory

#lxc-attach -n containerName -- bash -c 'echo "$(cat 2.sh)" > /root/2.sh'
->cat: 2.sh: No such file or directory


#lxc file push 2.sh containerName/root/
->Error: not found

The -> is the output

Containers are built with lxc- and do not appear in the lxc list list, but in the lxc-ls list.

Any help is welcome

Score:0
in flag

Try this:

cat 2.sh | lxc-attach -n containerName tee /root/2.sh

Note:

I tested this with docker containers, as I don't have lxc available at the moment. With docker this works when the -i parameter for an interactive session is specified. I don't see a corresponding parameter for lxc-attach, I don't know if this is necessary or possible.

mq flag
Well, the truth is that no, if they don't have the format indicated above directly, they don't work. But +1 for teaching me how to do that in docker. I leave an example `cat 2.sh | docker exec -i name_container tee /root/2.sh`
mq flag
I leave this comment to remind myself that I owe a +1 to [@gerald-schneider](https://serverfault.com/users/38644) (When I do I will delete this message)
Score:0
mq flag

This solution only works in the case that the LXC is in a machine in which you can connect with SSH, DOES NOT WORK WITH VIRTULIZED LXC. You need access to the lxc folders!

cp /root/input/2.sh /var/lib/lxc/NAME_LXC/rootfs/root/2.sh

The truth is that it is a mess for me to understand LXC/LXD. Now I understand many things and it became clearer to me how it works from behind

The trick is that everything is based on physical files in this path /var/lib/lxc/

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.