Skip to content

Instantly share code, notes, and snippets.

@xyzkpz
Forked from developerinlondon/docker.md
Created September 5, 2021 08:51
Show Gist options
  • Save xyzkpz/67af55d86ec45745a5deffa6c2ec146b to your computer and use it in GitHub Desktop.
Save xyzkpz/67af55d86ec45745a5deffa6c2ec146b to your computer and use it in GitHub Desktop.
Docker saving and loading images

Here's how to save and load docker images:

Example scenario: To save a docker image from a docker repository and save it as a tar file locally.

  1. Save the image as a tarball

docker save repositoryname:tag > repotag.tar

  1. Zip the image

gzip repotag.tar

  1. Copy the tarball to the new machine.

scp repotag.tar.gz <foreign machine>

  1. Unzip The tarball

gunzip repotag.tar.gz

  1. Load the docker image

docker load < repotar.tar

  1. Find the Image ID

docker images

  1. Tag the image

docker tag repositoryname:tag

@xyzkpz
Copy link
Author

xyzkpz commented Oct 3, 2022

To instruct tar to put the extracted unzipped files into a specific directory, enter:
tar –xvzf documents.tar.gz –C /home/user/destination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment