Real-Time Scenario: Migrating Docker Images from Production Server (XYZ Project)

You’re working on the XYZ Project, and you’ve been asked to migrate Docker images (backend, frontend, and Redis cache) from a production Ubuntu server to your local development laptop for testing or backup purposes.


πŸ” Docker Images on the Server

Run the command on the server:

docker images

Output:

REPOSITORY                             TAG                   IMAGE ID       SIZE
10.0.4.65:5000/live/xyz-api 2021-08-19-10.48.18 6594170ff931 320MB
10.0.4.65:5000/live/xyz-frontend 2021-03-23-06.20.43 772dff78c9a8 32.4MB
redis 3-alpine 6e94a98d3442 22.9MB

βœ… Step 1: Save Docker Images as .tar Files

On the production server (ubuntu@xx.xxx.xxx.xxx):

docker save -o xyz-api.tar 10.0.4.65:5000/live/xyz-api
docker save -o xyz-frontend.tar 10.0.4.65:5000/live/xyz-frontend
docker save -o redis.tar redis:3-alpine

βœ… Step 2: Compress the TAR Files

To reduce size for transfer:

gzip xyz-api.tar
gzip xyz-frontend.tar
gzip redis.tar

This creates:

  • xyz-api.tar.gz
  • xyz-frontend.tar.gz
  • redis.tar.gz

βœ… Step 3: Download Images to Local Laptop

On your local laptop, run:

scp -i xyz-project-key.pem ubuntu@13.49.237.139:/home/ubuntu/xyz-api.tar.gz .
scp -i xyz-project-key.pem ubuntu@13.49.237.139:/home/ubuntu/xyz-frontend.tar.gz .
scp -i xyz-project-key.pem ubuntu@13.49.237.139:/home/ubuntu/redis.tar.gz .

βœ… Step 4: Load Images into Docker Locally

On your local machine:

gunzip xyz-api.tar.gz
docker load -i xyz-api.tar

gunzip xyz-frontend.tar.gz
docker load -i xyz-frontend.tar

gunzip redis.tar.gz
docker load -i redis.tar

🎯 Outcome

Now you have the same Docker images running locally as on the production server. This is helpful for debugging, backup, testing, or migration.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top