Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

The Docker export command

The Docker export command

Docker Command ReferenceDocker Command Reference


docker export This command exports a Docker container's filesystem as a tar archive.

docker export It is mainly used to back up or migrate a container's filesystem, excluding the image's layers and metadata.

Syntax

docker export [OPTIONS] CONTAINER

OPTIONS description:

Export a container's filesystem:



docker export my_container

Export the filesystem of the container named my_container to standard output.

Save the exported file as a tar file:



docker export my_container > my_container_backup.tar

Export the filesystem of container my_container and save it to the file my_container_backup.tar.

Save the exported file using the --output option:

sh



docker export -o my_container_backup.tar my_container

Export the filesystem of container my_container and save it to the file my_container_backup.tar.

Example

Start a container:



docker run -d --name my_container ubuntu bash -c "echo hello > /hello.txt && sleep 3600"

Export the container's filesystem:



docker export my_container > my_container_backup.tar

View the contents of the exported tar file:



tar -tf my_container_backup.tar

Output:



hello.txt

Import the filesystem into a new container:



cat my_container_backup.tar | docker import - my_new_image

Notes

docker export This command is a useful tool for exporting a container's filesystem as a tar archive. It is very useful for backing up, migrating, and analyzing a container's filesystem. By using the --output option, users can save the exported content to a specified file for easy management and use.


Docker Command ReferenceDocker Command Reference