Export Filesystem of Docker Container to Tar File

Export Filesystem of Docker Container to Tar File

A tar is an archive file (.tar) that allows to store a collection of files and directories. For backup or sharing purpose, it can be useful to export a filesystem of Docker container that can be later imported as a Docker image. This tutorial shows how to export a filesystem of Docker container to tar file.

The docker export command, or docker container command with export argument, can be used to export a filesystem of Docker container to a tar file. For example, to export container nginx to the nginx_container.tar file, you can use:

docker export nginx -o nginx_container.tar
docker container export nginx -o nginx_container.tar

The command exports all the files and directories created in the container. However, the command does not export the contents of volumes that are mounted on the container.

Leave a Comment

Cancel reply

Your email address will not be published.