Fixes #5224 transfering container and metadata ownership