matt wilkie's picture

Thinking a background script is automatically spawning the controller I periodically checked the running status with `lxc-ls -f` and `lxc-info` while I did other things. The goal being to determine the schedule and time the destroy command accordingly. Didn't work, the state is always stopped until I run lxc-destroy. I even tried chaining together in a single command with `&&`.

I then tried to login to the container and shut it down from inside, using `lxc-console`, but got stuck in a loop. It wouldn't recognize my password. I tried the ones from inithook, the master lxc password, and some others just for fun. All of them were unrecognized. There was no way to break out of the login cycle, to say "I give up! let me out!". I had to open another ssh session. Sometimes when I hit [enter] at the end of my password an 's' would show on screen, so my guess is the right keys weren't being sent through.

I tracked down the lxc-destroy script and stepped through, manually running the lines I can understand. Ahhh! This is what's booting up the container again:

root@lxc ~# lxc-info -n domain-controller
Name:           domain-controller
State:          STOPPED

root@lxc ~# which lxc-destroy
/usr/local/bin/lxc-destroy

###...inspect script...

root@lxc ~# /usr/local/bin/lxc-dnsmasq-update --delete domain-controller
Container domain-controller not connected:

root@lxc ~# lxc-info -n domain-controller
Name:           domain-controller
State:          RUNNING
PID:            10711
CPU use:        3.37 seconds
BlkIO use:      688.00 KiB
Memory use:     61.28 MiB
KMem use:       10.48 MiB

And now we are successful:

root@lxc ~# lxc-stop -n domain-controller
root@lxc ~# lxc-ls -f
NAME              STATE   AUTOSTART GROUPS IPV4 IPV6
domain-controller STOPPED 0         -      -    -

# RUN THE REAL SHIVA DESTROYER OF WORLDS
root@lxc ~# /usr/bin/lxc-destroy -n domain-controller
Destroyed container domain-controller


root@lxc ~# ls /var/lib/lxc/
lxc-monitord.log
### ...sub dirs are gone...

root@lxc ~# nginx-proxy -r -d all -n "domain-controller"
root@lxc ~# ssh-keygen -R "domain-controller"
do_known_hosts: hostkeys_foreach failed: No such file or directory
root@lxc ~#