docker implements export import and data relocation
- 2020-06-19 12:04:46
- OfStack
There are two types of docker exports and imports, one is a backup image, and the other is a backup container. Data relocation, the most simple and brutal is direct COPY, volume path on the line.
1 ,导出导入镜像
# Export to tar
docker save #ID or #Name > /home/save.tar
# The import tar
docker load < /home/save.tar
2. Export into the container
# Export to tar
docker export #ID or #Name > /home/export.tar
# The import tar
cat /home/export.tar | docker import - test:1.0
3. Data migration
1. volume is set when the container is generated, and the directory after COPY is directly sent to the new server or path
2, and then docker run specifies --volume to the new path.
If you don't know - volume path to cd/var/lib/docker containers/find below the corresponding container. There is a configuration file
# cat hostconfig.json
{"Binds":["/home/docker/redmine/redmine:/home/redmine/data"],"ContainerIDFile":"",
/ home docker/redmine/redmine, this is I set -- volume, if not set - volume can also be found here