How to restore Docker volumes on a different host?

It means that you created the volume manually not using Docker Compose, but Docker Compose will not be able to reuse it if it was not the one that created it. One solution is mentioned in the error message. You can add it to the volume definition in the compose file.

You could use compose to create the volume by running “docker compose up”, stopping the project and overriding the content of the created volumes, or you can manually set the labels that helps compose recognize the volume as created by compose

docker volume create compose_data2 \
  --label com.docker.compose.project=compose

The value of the label should be the actual compose project name. You could add the rest of the labels too, but this single label is enough to let compose use the volume. You can inspect a volume created by compose to see what other labels exist, but here is an output from my machine

docker volume inspect compose_data
[
    {
        "CreatedAt": "2025-06-18T18:18:12Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.config-hash": "bdac2a6221b3c822ff2c1107cfd3a0af7a8edf4ddef0ff8d7116285754a7f4e7",
            "com.docker.compose.project": "compose",
            "com.docker.compose.version": "2.36.1",
            "com.docker.compose.volume": "data"
        },
        "Mountpoint": "/var/lib/docker/volumes/compose_data/_data",
        "Name": "compose_data",
        "Options": null,
        "Scope": "local"
    }
]