top of page

How to Efficiently Save Docker Images and Containers: The Ultimate Guide


Docker Save

'Docker save' is a command-line utility used to save one or more Docker images to a tar archive. It packages the image along with its layers, dependencies, and metadata into a single file, allowing for easy storage, sharing, and transportation across different Docker environments. Let's delve into its syntax and common usage scenarios.


Syntax:

The syntax for using 'docker save' is as follows:

docker save [OPTIONS] IMAGE [IMAGE...]

Where:


OPTIONS: Additional flags to customize the behaviour of the command.

IMAGE: The name of the Docker image(s) you want to save.


[root@siddhesh ~]# docker images
REPOSITORY        TAG       IMAGE ID       CREATED        SIZE
nginx             latest    c20060033e06   3 months ago   187MB
centos            latest    5d0da3dc9764   2 years ago    231MB
google/cadvisor   latest    eb1210707573   5 years ago    69.6MB
[root@siddhesh ~]#
[root@siddhesh ~]# docker save nginx > /opt/backup_nginx.tar

The command docker save is used to save one or more images to a tar archive. In this case, we're saving the Nginx image with the ID c20060033e06 into a file named backup_nginx.tar located in the /opt directory.

Here's what each part of the command does:

docker save c20060033e06: This part of the command specifies that you want to save the Docker image with the ID c20060033e06. This image corresponds to Nginx, as per your docker images output.

> /opt/backup_nginx.tar: This part of the command directs the output of the docker save command to a file named backup_nginx.tar in the /opt directory. The > symbol is used for output redirection in Unix-like systems.

So, after running this command, you will have a tar archive named backup_nginx.tar in the /opt directory, containing the Nginx Docker image.

Comentarios

Obtuvo 0 de 5 estrellas.
Aún no hay calificaciones

Agrega una calificación
bottom of page