Why docker-compose down deletes my volume? how to define volume as external?

The documentation is absolute unclear, because the “by default” block contradicts with the sentence above and under when it commes to volumes. True is that everything that was created with up gets removed/deleted on down.

services, networks and named volumes declared in a compose.yml are bound to the lifecylce of docker-compose.

You need to create your volume from the cli (docker volume create ....), and declare it in your compose.yml as external.

2 Likes