This is documented.
I'm confused by how docker-compose decides to name volumes, prefixing a garbled directory path to the volume name. Consequently if you rename the directory, a new volume is created.
So I wanted to export the volume contents as a .tar.
MOUNT=/usr/share/elasticsearch/data; \
for VOLUME in {mariner,data_parsers_mariner,optdata_parsers_mariner}_elasticsearch_data; do \
sudo docker run --rm -v $VOLUME:$MOUNT -v /data/backup:/backup ubuntu \
tar cvf /backup/$VOLUME.tar $MOUNT; \
done
The $MOUNT path is where the volume actually gets mounted. I had 3 different potential volumes listed by docker volume list and I didn't know which one was actually being used, so I just backed them all up.
The new volumes can be created without starting the services with: docker-compose up --no-start
Then the tarball can be restored with:
MOUNT=/usr/share/elasticsearch/data; \
NEW_VOLUME=mariner_elasticsearch_data; \
OLD_VOLUME=data_parsers_mariner_elasticsearch_data; \
sudo docker run --rm -v $NEW_VOLUME:$MOUNT -v /data/backup:/backup ubuntu \
tar xvf /backup/$OLD_VOLUME.tar