How to Export Docker Container?
The docker export command does not export the contents of volumes associated with the container. If a volume is mounted on top of an existing directory in the container, docker export will export the contents of the underlying directory, not the contents of the volumes.
--output, -o Write to a file, instead of STDOUT
$ docker export red_panda (greaterthan angle bracket symbol) latest.tar
or
$ docker export --output="latest.tar" red_panda
Export Commands:
docker export c1 > c1backup.tar
docker export -o='c2backup.tar' c1
[root@localhost ~]# docker images |grep c1backup.tar
[root@localhost ~]# ls
anaconda-ks.cfg c1backup.tar Dockerfile hello-world
Import Commands:
[root@localhost ~]# docker import c1backup.tar backup:v1
sha256:ac48e627777e035b65cadb144e05bea4dbcdbbd9289310c73bd12d5552a75cfb
[root@localhost ~]# docker run -it -d --name mybackup backup:v1 bash
19e8b31ca95f03dec29a7b4b0e3e66510ab3a931e5b807eac0b4b79b5ef9c05e
To extract tar file & check its content
$ mkdir Ubuntu && tar -xf mybackup.tar -C Ubuntu
Extract and see the tar file content.
mkdir Ubuntu && tar -xf c1backup.tar -C Ubuntu
cd Ubuntu/
ls
bin boot dev etc home lib lib32 lib64 libx32 media mnt opt proc qader root run sbin srv sys tmp u01 usr var
No comments:
Post a Comment