🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
In this guide, we'll explore how to archive one or more Docker images as tar files. We also see how to reload the tar file into the original Docker image.
Check out all Docker tutorials and guides: Docker Tutorials and Guides
Why Save Docker Images as TAR?
There are several scenarios where saving a Docker image as a TAR file proves invaluable:
Offline Deployment: Deploy containers to an environment without internet access.
Backup: Creating backups of specific image versions.
Migration: Moving images between different systems or Docker instances without pulling from a registry.
Sharing: Distributing images without using Docker Hub or any private registry.
Introducing the docker save Command
The primary purpose of the docker save command is to serialize one or more Docker images into a tar archive. This tarball can then be transferred to other systems, backed up, or even shared with colleagues or the community.
The general syntax is:
docker save [OPTIONS] IMAGE [IMAGE...]IMAGE: Specifies the name or ID of the Docker image you intend to save.
Examples
Saving a Single Image:
To save an image named myapp to a tar archive:
docker save -o myapp.tar myappThe -o (or --output) flag allows you to specify the name of the output file.
Saving Multiple Images:
If you wish to bundle several images into one archive:
docker save -o bundled_images.tar myapp1 myapp2 myapp3Compressing the Archive:
While docker save creates a tar archive, you might want to further compress it to save space. This isn't a built-in feature of docker save, but you can use typical compression tools:
docker save myapp | gzip > myapp.tar.gzReloading the Image:
To load an image from a TAR file back into Docker, use the docker load command:
docker load -i <path-to-tar-file>For our example:
docker load -i my-app.tarThe image will be restored to your Docker instance.
Conclusion
In essence, docker save offers Docker users a flexible method to capture and share their container images. Whether you're performing a system migration, prepping offline deployments, or simply sharing your latest app with a colleague over a USB stick, saving Docker images as TAR files make the process seamless. The next time you want to snapshot your container, remember this Docker magic trick!
Related Docker Image Management Guides
- Docker Create Image From Dockerfile
- Docker List Images
- Docker Remove Images
- Docker Pull Image From Registry (Docker Hub)
- Docker Push an Image to Registry (Docker Hub)
- Docker Save Image as TAR
- Docker Remove Unused Images
- Docker Rename image
My Top and Bestseller Udemy Courses. The sale is going on with a 70 - 80% discount. The discount coupon has been added to each course below:
Build REST APIs with Spring Boot 4, Spring Security 7, and JWT
[NEW] Learn Apache Maven with IntelliJ IDEA and Java 25
ChatGPT + Generative AI + Prompt Engineering for Beginners
Spring 7 and Spring Boot 4 for Beginners (Includes 8 Projects)
Available in Udemy for Business
Building Real-Time REST APIs with Spring Boot - Blog App
Available in Udemy for Business
Building Microservices with Spring Boot and Spring Cloud
Available in Udemy for Business
Java Full-Stack Developer Course with Spring Boot and React JS
Available in Udemy for Business
Build 5 Spring Boot Projects with Java: Line-by-Line Coding
Testing Spring Boot Application with JUnit and Mockito
Available in Udemy for Business
Spring Boot Thymeleaf Real-Time Web Application - Blog App
Available in Udemy for Business
Master Spring Data JPA with Hibernate
Available in Udemy for Business
Spring Boot + Apache Kafka Course - The Practical Guide
Available in Udemy for Business
Comments
Post a Comment
Leave Comment