diff --git a/src/core/namespace.c b/src/core/namespace.c index 33349f288e..f1ab6f9736 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -1152,10 +1152,6 @@ int setup_namespace( } } - /* Try to set up the new root directory before mounting anything there */ - if (root) - (void) base_filesystem_create(root, UID_INVALID, GID_INVALID); - if (root_image) { /* A root image is specified, mount it to the right place */ r = dissected_image_mount(dissected_image, root, dissect_image_flags); @@ -1192,6 +1188,10 @@ int setup_namespace( } } + /* Try to set up the new root directory before mounting anything else there. */ + if (root_image || root_directory) + (void) base_filesystem_create(root, UID_INVALID, GID_INVALID); + if (n_mounts > 0) { _cleanup_fclose_ FILE *proc_self_mountinfo = NULL; char **blacklist;