How to make volumes permanent with Docker Compose v2 : <p><em>I realize other people have had similar questions but this uses v2 compose file format and I didn't find anything for that.</em></p>

<p>I want to make a very simple test app to play around with MemSQL but I can't get volumes to not get deleted after <code>docker-compose down</code>. If I've understood Docker Docs right, volumes shouldn't be deleted without explicitly telling it to. Everything seems to work with <code>docker-compose up</code> but after going down and then up again all data gets deleted from the database.</p>

<p>As recommended as a good practice, I'm using separate memsqldata service as a separate data layer.</p>

<p>Here's my docker-compose.yml:</p>

<pre><code>version: '2'
services:
    app:
        build: .
        links:
            - memsql
    memsql:
        image: memsql/quickstart
        volumes_from:
            - memsqldata
        ports:
            - "3306:3306"
            - "9000:9000"
    memsqldata:
        image: memsql/quickstart
        command: /bin/true
        volumes:
            - memsqldatavolume:/data

volumes:
    memsqldatavolume:
        driver: local
</code></pre>
