Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save AysadKozanoglu/1d85fc7010f033302b634fb0428f4be4 to your computer and use it in GitHub Desktop.

Select an option

Save AysadKozanoglu/1d85fc7010f033302b634fb0428f4be4 to your computer and use it in GitHub Desktop.
migrate docker image to another server

on running docker prod envointment

build docker image from current docker

 docker build -t <DOCKERIMAGE-NAME> .

info: to find out which image you want to migrate enter docker images you will see the images by name

Save the image to a tar file to transfer as a single file

docker save -o <DOCKERIMAGE-NAME>.tar <DOCKERIMAGE-NAME>:latest

now you can copy the tar file via rsync or scp , i prefer scp

scp <DOCKERIMAGE-NAME>.tar <USER>@<REMOTE_IP>:/tmp/

Load the image into local Docker

docker load -i <DOCKERIMAGE-NAME>.tar

If you're using Docker Compose, then run the container via

docker compose up -d <DOCKERIMAGE-NAME>

OR directly

docker run --name <DOCKERIMAGE-NAME> -d <DOCKERIMAGE-NAME>:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment