Is there something missing in docker getting-started tutorial?

TL;DR;

Run the command

docker-compose down --volumes

to remove any problematic volume created during the tutorial early phases, then, resume your tutorial at the step Running our Application Stack.


I suppose that the tutorial you are following is this one.

If you did follow it piece by piece and tried some docker-compose up -d in the step 1 or 2, then you've probably created a volume without your todos database.

Just going docker-compose down with your existing docker-compose.yml won't suffice because volumes is exactly made for this, the volume is the permanent storage layer of Docker.

By default all files created inside a container are stored on a writable container layer. This means that:

  • The data doesn’t persist when that container no longer exists, and it can be difficult to get the data out of the container if another process needs it.
  • A container’s writable layer is tightly coupled to the host machine where the container is running. You can’t easily move the data somewhere else.
  • Writing into a container’s writable layer requires a storage driver to manage the filesystem. The storage driver provides a union filesystem, using the Linux kernel. This extra abstraction reduces performance as compared to using data volumes, which write directly to the host filesystem.

Docker has two options for containers to store files in the host machine, so that the files are persisted even after the container stops: volumes, and bind mounts. If you’re running Docker on Linux you can also use a tmpfs mount. If you’re running Docker on Windows you can also use a named pipe.

Source: https://docs.docker.com/storage/

In order to remove that volume, you probably created without your database there is an extra flag you can add to docker-compose down: the flag --volumes or, in short -v

-v, --volumes           Remove named volumes declared in the `volumes`
                            section of the Compose file and anonymous volumes
                            attached to containers.

Source: https://docs.docker.com/compose/reference/down/

So your fix should be as simple as:

  1. docker-compose down --volumes
  2. docker-compose up -d, so back in your tutorial at the step Running our Application Stack
  3. docker-compose logs -f as prompted in the rest of the tutorial