try to unmount rootfs also during destroy_container
This commit is contained in:
parent
7794ada45e
commit
ca10263696
@ -60,7 +60,7 @@ parser_cleanup.add_argument('container', help='Container name')
|
||||
parser_cleanup.add_argument('lxc', nargs=argparse.REMAINDER)
|
||||
|
||||
parser_extract = subparsers.add_parser('extract', help='Extracts files or directories from containers rootfs (excluding persistent mounts)')
|
||||
parser_cleanup.set_defaults(action='extract')
|
||||
parser_extract.set_defaults(action='extract')
|
||||
parser_extract.add_argument('container', help='Container name')
|
||||
parser_extract.add_argument('source', help='Source file or directory within the container')
|
||||
parser_extract.add_argument('destination', help='Destination file or directory on the host')
|
||||
|
@ -20,7 +20,7 @@ def prepare_container(container, layers):
|
||||
layers = layers.split(',')
|
||||
mount_rootfs(container, layers, rootfs)
|
||||
|
||||
def mount_rootfs(container, layers, mountpoint)
|
||||
def mount_rootfs(container, layers, mountpoint):
|
||||
if len(layers) == 1:
|
||||
# We have only single layer, no overlay needed
|
||||
subprocess.run(['mount', '--bind', layers[0], mountpoint])
|
||||
@ -74,6 +74,8 @@ def create_container(container, image):
|
||||
|
||||
def destroy_container(container):
|
||||
# Remove container configuration and directories
|
||||
rootfs = os.path.join(LXC_ROOT, container, 'rootfs')
|
||||
unmount_rootfs(rootfs)
|
||||
try:
|
||||
shutil.rmtree(os.path.join(LXC_ROOT, container))
|
||||
except FileNotFoundError:
|
||||
|
Loading…
Reference in New Issue
Block a user