How to Remove Container Disk and Reclaim Space with Main Partition

bootcampdisk-utilitypartition

This is very similar to another question here, but the devil is in the details.
I had Bootcamp installed on my Macbook, was not able to delete it with bootcamp assistant, so tried to delete the partition with disk utility. But something went wrong, and I'm not able to delete the partition.
I'd like to have just a single partition with no leftover Windows. I ran "diskutil list" from the terminal, and this is the result:

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *251.0 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk2         149.0 GB   disk0s2
   3:                 Apple_APFS Container disk1         101.6 GB   disk0s3

/dev/disk1 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +101.6 GB   disk1
                                 Physical Store disk0s3

/dev/disk2 (synthesized):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      APFS Container Scheme -                      +149.0 GB   disk2
                                 Physical Store disk0s2
   1:                APFS Volume Macintosh HD            95.4 GB    disk2s1
   2:                APFS Volume Preboot                 44.7 MB    disk2s2
   3:                APFS Volume Recovery                512.4 MB   disk2s3
   4:                APFS Volume VM                      1.1 GB     disk2s4

Thanks!

Best Answer

The safest way would be to use macOS Recovery. Reboot and hold down +R key combination until the Mac boots to macOS Recovery. Open a Terminal application window and enter the following commands.

gpt -f remove -i 3 disk0
diskutil apfs resizecontainer disk0s2 0

An alternative quicker method would be to open a Terminal application window in macOS and enter the following commands.

sudo diskutil apfs deletecontainer disk0s3
sudo diskutil erasevolume free none disk0s3
sudo diskutil apfs resizecontainer disk0s2 0