Whenever I need to move containers here's all I do; I just backup any named volumes I need, and then restore them to the new host (I manually create the new named volume on the host first and import to it there).
Aside from that there's not much more to containers; the rest gets fetched when you re-deploy your compose file (or do docker run
).
# Backup
docker run --rm -v volume_name:/volume -v c:migrate:/backup alpine tar -cjf /backup/backup.tar.bz2 -C /volume ./
# Restore
docker run --rm -v volume_name:/volume -v c:migrate:/backup alpine tar -C /volume/ -xjf /backup/backup.tar.bz2
In my compose file I set those volumes as external so docker knows not to try to create them, and use the existing one(s):
i.e. if I created a named volume "my_bitwarden_data" then I'd use:
volumes:
my_bitwarden_data:
external: true
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…