Magento 2: New container not showing

David's answer is correct, but his example doesn't work (for me anyway).

If you swap the text block in his example with a template block you'll see the container then displays.

My full example to get it working:

app/design/frontend/PACKAGE/THEME/Magento_Cms/layout/default.xml

<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="footer">
            <container name="mike.container" as="mikeContainer" label="Mike Container" htmlTag="div" htmlClass="mike-container">
                <block class="Magento\Framework\View\Element\Template" name="testing" template="Magento_Cms::test.phtml" />
            </container>
        </referenceContainer>
    </body>
</page>

app/design/frontend/PACKAGE/THEME/Magento_Cms/templates/test.phtml

<h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptatem suscipit, adipisci, cum quos, alias similique ad eum at deserunt eligendi enim dignissimos, unde vero ipsam voluptatibus cumque accusantium! Obcaecati, quasi.</h2>

Result

enter image description here

If I remove the template block, the container is no longer rendered.


magento2 seems to render a container only if the children generate a html output: https://github.com/magento/magento2/blob/6ea7d2d85cded3fa0fbcf4e7aa0dcd4edbf568a6/lib/internal/Magento/Framework/View/Layout.php#L571

So I think you need to have at least one childblock with an output in order to have the container rendered

you should be able to test this with a text block like this:

<container name="mike.container" as="mikeContainer" label="Mike Container" htmlTag="div" htmlClass="mike-container">
    <block class="Magento\Framework\View\Element\Text" name="testtextblock">
        <arguments>
            <argument name="data" xsi:type="array">
                <item name="text" xsi:type="string">TestText</item>
            </argument>
        </arguments>
    </block>
</container>