Docker Load Command
# Docker load Command
[Docker Command Manual](#)
* * *
The `docker load` command is used to load Docker images from a tar file generated by the `docker save` command. It can load the images and all their layers from the archive into Docker, making them usable in a new environment.
### Syntax
docker load
OPTIONS Description:
* **`-i, --input`**: Specifies the path to the input file.
* **`-q, --quiet`**: Quiet mode, reduces output information.
1. Load an image from a file
docker load -i myimage.tar
This will load the image from the myimage.tar file.
2. Load an image from standard input
cat myimage.tar | docker load
This will load the image via a pipe from standard input.
## Examples
**1. Build and Save an Image**
First, build a sample image and save it. Create a Dockerfile:
# Use Ubuntu as the base image FROM ubuntu:20.04# Add maintainer information LABEL maintainer="yourname@example.com"# Update package list and install Nginx RUN apt-get update && apt-get install -y nginx # Copy custom webpage to Nginx's default web directory COPY index.html /var/www/html/# Set the default command on startup CMD ["nginx", "-g", "daemon off;"]
Build the image:
docker build -t mynginx:latest .
Save the image to a file:
docker save -o mynginx.tar mynginx:latest
**2. Load the Image**
Load the image from the file:
docker load -i mynginx.tar
**3. Verify the Loaded Image**
docker images
Example output:
REPOSITORY TAG IMAGE ID CREATED SIZE mynginx latest 123abc456def 1 minute ago 200MB
### Notes
* The loaded image includes all its layers and metadata, exactly as it was when saved.
* When using `docker load`, all images contained in the tar file will be loaded.
* The loading process may take some time, depending on the image size and system performance.
The `docker load` command is a convenient way to restore Docker images from saved tar files. By combining `docker save` and `docker load`, users can easily back up, distribute, and migrate Docker images across different environments.
* * Docker Command Manual](#)
YouTip