tar the volumes wikijs_wikijs_config and wikijs_wikijs_data from the source host after shutting down the container
scp the tar to the new host
create a Docker volume on the new host
finally untar the copied tar-file into the newly created docker volume
start the container on the new host with Docker compose
Unfortunately when powering up the container with docker compose I get the following error:
WARN[0000] volume “wikijs_wikijs_config” already exists but was not created by Docker Compose. Use external: true to use an existing volume
WARN[0000] volume “wikijs_wikijs_data” already exists but was not created by Docker Compose. Use external: true to use an existing volume
What does this error message exactly mean and what can I do?
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
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
Thanks a lot rimelek for your fast reply and help that made me think about it again.
I changed my workflow completely because nowadays I prefer bind mounts over volumes so I:
restored the content of the archived volumes to different directories on the new host
changed the owner of the new directories acordingly
finally changed my docker-compose.yaml to use bind mounts instead of volumes
after powering up the container everything now works like a charm
Yes, compared to local volumes, a bind mount could often be better. There are exceptions like when using Docker Desktop on Windows without WSL or when you want data to be copied from an image to the volume without worrying about permissions, but since you already had the content in tar files, a bind mount could work well on Linux.