A tar is an archive file (.tar
) that allows to store a collection of files and directories. Sometimes can be useful to make Docker image backup, move image to other server or share image with others. This tutorial shows how to save the Docker image to a tar file.
Save image to tar file
To save the Docker image to a tar file, use docker save
command or docker image
command with save
argument. The file name is provided with -o
option. For example, to save an image nginx:latest
to the nginx_backup.tar
file, you can use:
docker save nginx:latest -o nginx_backup.tar
docker image save nginx:latest -o nginx_backup.tar
Save image to tar gz file
A tar archive file can be compressed using gzip algorithm. It allows making the backup smaller. Compression can be done using gzip
command as follows:
docker save nginx:latest | gzip > nginx_backup.tar.gz
docker image save nginx:latest | gzip > nginx_backup.tar.gz
Leave a Comment
Cancel reply