Is it safe to remove APFS containers?

I have upgraded my Mac to High Sierra. So I was just looking at the features when I saw APFS container in Disk Utility. I googled it and found out that it is used for multiple logical drives but I thought I don't require it so is it safe to delete the containers?

PS. I would also like to know the other features of APFS containers.

Output of diskutil apfs list:

APFS Container (1 found)
|
+-< Container disk1 2EE47F12-9699-433D-AECF-167CB27FDDF0
    ====================================================
    APFS Container Reference:     disk1
    Capacity Ceiling (Size):      121123069952 B (121.1 GB)
    Capacity In Use By Volumes:   39590055936 B (39.6 GB) (32.7% used)
    Capacity Available:           81533014016 B (81.5 GB) (67.3% free)
    |
    +-< Physical Store disk0s2 7E9192B8-7976-4CBF-AE7C-C7B9D5E49F65
    |   -----------------------------------------------------------
    |   APFS Physical Store Disk:   disk0s2
    |   Size:                       121123069952 B (121.1 GB)
    |
    +-> Volume disk1s1 578EF44C-A052-3F3F-BBE4-B254D82C57F2
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s1 (No specific role)
    |   Name:                      Macintosh HD (Case-insensitive)
    |   Mount Point:               /
    |   Capacity Consumed:         37848293376 B (37.8 GB)
    |   Encrypted:                 No
    |
    +-> Volume disk1s2 2DC1D14B-7E91-4F17-83CE-40E5435303FE
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s2 (Preboot)
    |   Name:                      Preboot (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         21651456 B (21.7 MB)
    |   Encrypted:                 No
    |
    +-> Volume disk1s3 3C4A7A25-7E07-48EC-B942-4DA9007D1538
    |   ---------------------------------------------------
    |   APFS Volume Disk (Role):   disk1s3 (Recovery)
    |   Name:                      Recovery (Case-insensitive)
    |   Mount Point:               Not Mounted
    |   Capacity Consumed:         519995392 B (520.0 MB)
    |   Encrypted:                 No
    |
    +-> Volume disk1s4 57093D4B-CDF1-4286-BC5C-6ED2DB620DD1
        ---------------------------------------------------
        APFS Volume Disk (Role):   disk1s4 (VM)
        Name:                      VM (Case-insensitive)
        Mount Point:               /private/var/vm
        Capacity Consumed:         1073762304 B (1.1 GB)
        Encrypted:                 No

Solution 1:

It's not safe to remove your container - but it shouldn't work anyway.

The container disk1 with the physical base disk0s2 contains your boot partition (disk1s1), the recovery partition (disk1s3), a partition with the virtual memory file(s) (disk1s4) and the preboot partition (disk1s2).

Solution 2:

TL;DR: To do a perfect clean wipe and reinstall in APFS now you need the terminal in recovery in addition to Disk Utility. It has to do with the container which is the new base volume scheme in APFS.

For your information, I upgraded my 2017 MBP to High Sierra since beta 9, and decided to clean wipe and reinstall immediately afterwards (makes me feel better reassured with all the APFS conversion). I checked the output

diskutil apfs list

both before and after, and realized how my recovery volume inside the new APFS container has grown in size from ~500 MB to 1.1 GB.

Not letting that go, I did another clean install when the GM candidate arrived and sure enough the recovery has grown by another ~500 MB to 1.6GB. Not that this is likely going to happen to you but disk space is still disk space - Macintosh HD actually shrinks even under the shared volume scheme. With the arithmetic progression I'm pretty sure the recovery volume is not being overwritten but rather added upon every clean install.

After some time figuring how some of the things now work in APFS I found the caveat. When I wipe my disk through Disk Utility within recovery I can only wipe the Macintosh HD volume that sits within the

Container disk1

but not the container or the disk itself like we've been doing pre-APFS. Even when you show all volumes in Disk Utility you'll get an error message if you do that. So the other 3 volumes (Preboot, Recovery, VM) are untouched - I was just doing a somewhat "unclean wipe".

The workaround is, with APFS now we have to open up terminal under utilities in recovery, then do

diskutil apfs deleteContainer disk0s2

assuming your container is linked there. Now it will create a single empty volume named "Untitled" under your physical disk media as shown in Disk Utility.

We're not done yet - you have to go to that disk, e.g. "APPLE SSD...", then click erase in APFS format named Macintosh HD (or any name you wish), in order to set up the correct APFS container structure ready for you to install the OS back in place. The other 3 volumes sharing the container will not be there yet, but fear not, they will be automatically created when you install the OS.