When a container is created, we need to populate the VMID and the NODE name into the LXC guest.
Tried the following in vain:
inside the post-start section of the hookscript.
There was a "-c" parameter referred to in this post for pct exec that is no longer available.
See this article.
What is the pct equivalent to lxc-attach and what are issues to lookout for when using the latter?
Examples for pct exec would be useful.
It gets deeper - after creating an LXC instance but before starting it:
So we cannot push files into a mounted but not yet running container!
The push would have taken care of file ownerships.
Furthermore, we cannot set the hookscript if the container is mounted (locked) so we unmount it and then set it with:
See this post.
Tried the following in vain:
Perl:
system("pct exec $vmid -- echo $vmid $node > /root/VMID-NODE");
There was a "-c" parameter referred to in this post for pct exec that is no longer available.
See this article.
What is the pct equivalent to lxc-attach and what are issues to lookout for when using the latter?
Examples for pct exec would be useful.
It gets deeper - after creating an LXC instance but before starting it:
Bash:
pct mount 101
# Upload file from host to LXC guest at /var/lib/lxc/101/rootfs/root
# chown 100000:100000 /var/lib/lxc/101/rootfs/root/get_vmid_node.sh
# chmod 755 /var/lib/lxc/101/rootfs/root/get_vmid_node.sh
pct push 101 /root/get_vmid_node.sh /root/get_vmid_node_1.sh
can only push files to a running CT
The push would have taken care of file ownerships.
Furthermore, we cannot set the hookscript if the container is mounted (locked) so we unmount it and then set it with:
Bash:
pct unmount 101
pct set 101 --hookscript local:snippets/lxc_hookscript.pl
pct config 101
arch: i386
cores: 1
hookscript: local:snippets/lxc_hookscript.pl
hostname: sqlamp
memory: 512
net0: name=eth0,bridge=vmbr0,firewall=1,gw=192.168.0.1,hwaddr=AA:BB:CC:DD:EE:FF,ip=192.168.0.101/24,type=veth
ostype: debian
rootfs: local:101/vm-101-disk-0.raw,size=8G
swap: 512
unprivileged: 1
Last edited: