lxc 파일 보내기 또는 복사

lxc 파일 보내기 또는 복사

lxc로 파일을 복사하려고 하는데 벌써 절박합니다. 내가 시도한 몇 가지 명령은 다음과 같습니다.

#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

->출력 은 다음과 같습니다

컨테이너는 목록 lxc-에 표시되지 않고 목록 lxc list에 표시됩니다 lxc-ls.

어떤 도움이라도 환영합니다

답변1

이 시도:

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

메모:

현재 lxc를 사용할 수 없기 때문에 docker 컨테이너로 이것을 테스트했습니다. docker를 사용하면 -i대화형 세션에 대한 매개변수가 지정될 때 작동합니다 . 에 해당하는 매개변수가 표시되지 않습니다 lxc-attach. 이것이 필요한지 또는 가능한지 모르겠습니다.

답변2

이 솔루션은 LXC가 SSH로 연결할 수 있는 시스템에 있는 경우에만 작동합니다.가상화된 LXC에서는 작동하지 않습니다.. lxc 폴더에 액세스해야 합니다!

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

사실 LXC/LXD를 이해하는 것은 나에게는 엉망이다. 이제 나는 많은 것을 이해했고 그것이 뒤에서 어떻게 작동하는지 더 명확해졌습니다.

비결은 모든 것이 이 경로의 실제 파일을 기반으로 한다는 것입니다./var/lib/lxc/

관련 정보