...
Code Block | ||
---|---|---|
| ||
# stop
sudo lxc-stop --name my-container
# destroy
sudo lxc-destroy --name my-container
|
There is more to research,
Code Block | ||
---|---|---|
| ||
# snapshot # rename |
Cloning a Container
One of the most exciting aspects of containers is being able to clone (duplicate).
Shutdown (not entirely sure if needed but I do as principle) your container and clone from the host,
Code Block | ||
---|---|---|
| ||
# clone, but you still have to manually change the host file
sudo lxc-clone -o original -n new
sudo sed -i 's/original/new/' /var/lib/lxc/new/rootfs/etc/hosts # update host file
# rename |
Clone - after cloning make sure to manually update the hosts file as it still uses the older name.
...
Next boot up your container, log via the lxc console (is less steps) or ssh with a sudo enabled account and change your SSH host keys,
Code Block | ||
---|---|---|
| ||
sudo rm /etc/ssh/ssh_host_* # delete original keys
dpkg-reconfigure openssh-server # generate new keys |
If you chose to log in using ssh, you will want to log out and update your fingerprint file otherwise you will receive a "REMOTE HOST IDENTIFICATION HAS CHANGED!" error and not be able to ssh in. Different ways of doing this. On a Unix, Linux or Mac OS X operating system,
Code Block | ||
---|---|---|
| ||
ssh-keygen -R remote-server-name-here |
If you want to go the extra mile you might want to clear out or do a search and replace on your log files,
Code Block | ||
---|---|---|
| ||
/var/lib/lxc/t02app/rootfs/var/lib/dhcp/dhclient.eth0.leases
/var/lib/lxc/t02app/rootfs/var/log/auth.log
/var/lib/lxc/t02app/rootfs/var/log/syslog.1
/var/lib/lxc/t02app/rootfs/var/log/kern.log
/var/lib/lxc/t02app/rootfs/var/log/auth.log.1
/var/lib/lxc/t02app/rootfs/var/log/syslog
/var/lib/lxc/t02app/rootfs/var/log/kern.log.1
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_dsa_key.pub
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_ed25519_key.pub
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_ecdsa_key.pub
/var/lib/lxc/t02app/rootfs/etc/ssh/ssh_host_rsa_key.pub |
Share Folders with Host
... (this will be moved into a separate article)
...
Still to read - appears to be distilled LXC theory - http://the.binbashtheory.com/before-you-start-with-lxc-and-docker/#more-26
How to change ssh host keys - http://www.cyberciti.biz/faq/howto-regenerate-openssh-host-keys/