Question
How to move Docker containers from one Plesk Server to another?
Answer
The Docker extension allows to "Save as Image" existing containers and to "Upload image" to Docker for images saved locally.
Plesk now supports launching a Portainer container. Portainer is container management software that makes it easier to manage Docker containers. It also allows exporting from Docker and importing images to Docker.
Manual steps:
-
List all running docker images and take note of their IDs:
# docker ps
Additionally, take note of the container environment variables, either via Plesk UI or with this command:
# docker exec <container_id_or_name> env
-
On the source server, export the Docker container to a tarball file using the
docker export
command:# docker export -o /path/to/container.tar container_name_or_id
-
Transfer the container tarball to the destination server: Use a secure method to transfer the container tarball from the source server to the destination server, for example tools such as
scp
orrsync
:# scp /path/to/container.tar user@destination_server:/path/to/
-
On the destination server, import the Docker container from the tarball:
# docker import /path/to/container.tar new_image_name
-
After importing the container, run it on the destination server either from Plesk UI or from CLI after setting the environment variables taken from step 1:
# docker run -d --name new_container_name -p 8080:80 new_image_name
Adjust the options (
-d
,--name
,-p
, etc.) based as required. -
Verify and Test.
-
-
Verify that the container is running as expected on the destination server.
-
Check logs, ports, and any configurations specific to your application.
Note: this procedure assumes the Docker containers are self-contained and do not have dependencies outside the container. If containers have external dependencies or volumes, they will need to be managed accordingly. Additional proxy_pass directives for nginx are migrated via Plesk Migrator but should be reviewed nonetheless under container verification procedures.
-