Howto copy file from host to lxc container.

michaelvv

Renowned Member
Oct 9, 2008
103
3
83
Hi.

Howto copy file from host to lxc container.

From a script running at host without scp etc.

/Thanks Michael.
 
Last edited:
Newer version (i.e. pve-container_1.0-49_all.deb from pvetest) supports push/pull

# pct push <vmid> <file> <destination>

see

# pct help push
 
Try to get the packages from pvetest but this was not a success on the stable release.

#dpkg -i pve-container_1.0-49_all.deb pve-manager_4.1-18_amd64.deb

(Reading database ... 45116 files and directories currently installed.)
Preparing to unpack pve-container_1.0-49_all.deb ...
Unpacking pve-container (1.0-49) over (1.0-32) ...
Preparing to unpack pve-manager_4.1-18_amd64.deb ...
Unpacking pve-manager (4.1-18) over (4.1-1) ...
Setting up pve-container (1.0-49) ...
Setting up pve-manager (4.1-18) ...
Job for pvedaemon.service failed. See 'systemctl status pvedaemon.service' and 'journalctl -xn' for details.
dpkg: error processing package pve-manager (--install):
subprocess installed post-installation script returned error exit status 1
Processing triggers for man-db (2.7.0.2-5) ...
Processing triggers for systemd (215-17+deb8u3) ...
Errors were encountered while processing:
pve-manager

#systemctl status pvedaemon.service

● pvedaemon.service - PVE API Daemon
Loaded: loaded (/lib/systemd/system/pvedaemon.service; enabled)
Active: active (running) (Result: exit-code) since Wed 2016-03-09 07:36:52 CET; 7min ago
Main PID: 5227 (pvedaemon)
CGroup: /system.slice/pvedaemon.service
├─5227 pvedaemon
├─5228 pvedaemon worker
├─5229 pvedaemon worker
└─5230 pvedaemon worker

Mar 09 07:41:43 proxmox pvedaemon[12943]: Compilation failed in require at /usr/share/perl5/PVE/API2/Cluster.pm line 15.
Mar 09 07:41:43 proxmox pvedaemon[12943]: BEGIN failed--compilation aborted at /usr/share/perl5/PVE/API2/Cluster.pm line 15.
Mar 09 07:41:43 proxmox pvedaemon[12943]: Compilation failed in require at /usr/share/perl5/PVE/API2.pm line 13.
Mar 09 07:41:43 proxmox pvedaemon[12943]: BEGIN failed--compilation aborted at /usr/share/perl5/PVE/API2.pm line 13.
Mar 09 07:41:43 proxmox pvedaemon[12943]: Compilation failed in require at /usr/share/perl5/PVE/Service/pvedaemon.pm line 8.
Mar 09 07:41:43 proxmox pvedaemon[12943]: BEGIN failed--compilation aborted at /usr/share/perl5/PVE/Service/pvedaemon.pm line 8.
Mar 09 07:41:43 proxmox pvedaemon[12943]: Compilation failed in require at /usr/bin/pvedaemon line 11.
Mar 09 07:41:43 proxmox pvedaemon[12943]: BEGIN failed--compilation aborted at /usr/bin/pvedaemon line 11.
Mar 09 07:41:43 proxmox systemd[1]: pvedaemon.service: control process exited, code=exited status=255
Mar 09 07:41:43 proxmox systemd[1]: Reload failed for PVE API Daemon.


So I properly just need to wait some time :)
 
These packages currently depend on newer versions of the other packages as well (we don't track such version dependencies within the testing repository), so you'll have to either wait or use the full testing repository.
In the mean time you can cheat and pipe the file to `pct exec` like this:
Code:
# cat /your/source/file | pct exec $VMID -- sh -c 'cat > /your/destination/file'
Or to copy multiple files:
Code:
# tar cf - /some /files /or/directories | pct exec $VMID -- sh -c 'tar xf - -C /destination/directory'

(Or manually mount the container's disk images somewhere...)
 
Hi Wolfgang.

I did mount a host dir in the lxc, from my install script works fine.

Thanks for your suggestion I'll try them out.
 
  • Like
Reactions: tds29

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!