Hello,
There are a few ways to do that:
- 1. Export and import containers
This would essentially mean that you would compress the data to a file from the container’s file system. The data would be saved as a ‘gzip’ file. To do that run:
docker export CONTAINER_NAME | gzip > CONTAINER_NAME.gz
Then copy this file to the droplet and start the container with:
zcat CONTAINER_NAME.gz | docker import - CONTAINER_NAME
After that start the container on the new host with the docker run
command.
This is the most commonly used method. You would need to first create a docker image of the running container with the docker commit
command:
docker commit CONTAINER_ID IMAGE_NAME
Then you can push your image to docker hub:
docker image tag IMAGE_NAME YOUR_TAG
After that push your new image to docker hub. For that you would need a docker hub account first:
Login:
docker login
Push the image:
docker push YOUR_DOCKER_HUB_uSER/IMAGE_NAME
Then on your new droplet, login to docker hub again:
docker login
And pull your image:
docker pull IMAGE_NAME
The images can be compressed using docker save
and moved to a new host.
docker save IMAGE_NAME > IMAGE_NAME.tar
This would create a tarball of your local docker image which you could copy to your new server and re-deploy with the docker load
command:
docker load -i IMAGE_NAME.tar
If all went through successfully you should be able to see your new image with:
docker images
Hope that this helps!
Regards,
Bobby