Deleting Solaris Container

And finally for “completeness” of my Solaris Containers notes, here is a procedure to delete a container. You can not remove a container that is active. You have to halt it first. Start by finding out what containers are configured and what state they are in:

bash-3.00# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   - ns1              installed  /export/home/zones/ns1         native   shared

First you need to uninstall the container files. In the following step you can use -F switch and you will not be asked for confirmation:

bash-3.00# zoneadm -z ns1 uninstall
Are you sure you want to uninstall zone ns1 (y/[n])? y
bash-3.00# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   - ns1              configured /export/home/zones/ns1         native   shared

Next you need to erase any knowledge the global container might have related to the container you are removing:

bash-3.00# zonecfg -z ns1 delete
Are you sure you want to delete zone ns1 (y/[n])? y
bash-3.00# zoneadm list -cv
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared

You might have to manually remove container’s zonepath to tidy things up. That’s it.