How to migrate Docker Compose data (e.g. master_kafka-data-1) to a new server?

in older server I’m using Docker Compose to run a Kafka cluster with the following volume definitions:

volumes:
  kafka-data-1:
  kafka-data-2:
  kafka-data-3:

When the stack is deployed under the project name master, Docker creates these volumes:

  • master_kafka-data-1
  • master_kafka-data-2
  • master_kafka-data-3

I want to migrate these volumes and their data to a new server.
What are steps do it?
Thanks for your guidance.

I am curious why the forum search didn’t find any results for this topic. Can you share which search terms you used in the forum search?

I used the forum search and found an old post of mine. It should give you some inspiration:

So basically you create a temporary container to create an archive of a volumes content, copy the archive to the new host, deploy your compose project, but terminate it once the volumes are created, restore the volumes from the archives. Finally start your compose project and be good.

I am not sure if volumes created outside compose project will be claimed by the compose project, or result in an error. Since volumes created outside a compose project lack the labels that mark it as part of the project, I guess it will result in an error as the ressource already exists, but doesn’t belong to the compose project.

I hope it makes sense.