Fix wrong layer ordering

This commit is contained in:
Disassembler 2019-12-21 17:44:27 +01:00
parent bfd1b7cb2f
commit a1ceeb1ead
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -17,8 +17,7 @@ def prepare_container(container, layers):
rootfs = os.path.join(LXC_ROOT, container, 'rootfs') rootfs = os.path.join(LXC_ROOT, container, 'rootfs')
# Unmount rootfs in case it remained mounted for whatever reason # Unmount rootfs in case it remained mounted for whatever reason
unmount_rootfs(rootfs) unmount_rootfs(rootfs)
layers = layers.split(',') mount_rootfs(container, layers.split(','), rootfs)
mount_rootfs(container, layers, rootfs)
def mount_rootfs(container, layers, mountpoint): def mount_rootfs(container, layers, mountpoint):
if len(layers) == 1: if len(layers) == 1:
@ -26,7 +25,7 @@ def mount_rootfs(container, layers, mountpoint):
subprocess.run(['mount', '--bind', layers[0], mountpoint]) subprocess.run(['mount', '--bind', layers[0], mountpoint])
else: else:
olwork = os.path.join(LXC_ROOT, container, 'olwork') olwork = os.path.join(LXC_ROOT, container, 'olwork')
subprocess.run(['mount', '-t', 'overlay', '-o', 'upperdir={},lowerdir={},workdir={}'.format(layers[0], ':'.join(layers[1:]), olwork), 'none', mountpoint]) subprocess.run(['mount', '-t', 'overlay', '-o', 'upperdir={},lowerdir={},workdir={}'.format(layers[-1], ':'.join(reversed(layers[:-1])), olwork), 'none', mountpoint])
def unmount_rootfs(mountpoint): def unmount_rootfs(mountpoint):
if os.path.exists(mountpoint): if os.path.exists(mountpoint):