Yes you could definitely do it the other way using the export /import commands in docker.Let me walk you through the steps of exporting and importing your containers, so that you can rest assured that those containers can be even more portable than you thought.
The first thing you need to do is list out your containers. You'll be exporting them by name, so you need to know the names of those containers. To do this, issue the command:
docker ps -a
The resulting output will include the NAME column,It is this column where you will get your names for exporting.
Exporting a container
For ease of transport, we'll be exporting the containers into a gzipped file. The command to export the containers is:
docker export NAME | gzip > NAME.gz
Where NAME is the name of the container to be exported. You are now ready to relocate the file and import it.
Importing a container
In similar fashion to the export, we're going to import the container with a single command. Obviously, before you do this, you must first move the exported file to the new server. You could do this using the scp command like so:
scp NAME.gz USERNAME@SERVER_IP:/home/USERNAME
Where NAME is the file name, USERNAME is the user name on the remote server, SERVER_IP is the IP address of the remote server, and USERNAME is (again) the name of the user on the remote server.
Once you've done that, the import can be handled with the following command:
zcat NAME.gz | docker import - NAME
Where NAME is the name of the container. You can now run the newly imported container with a command similar to:
docker run -i -t NAME /bin/bash
Where NAME is the name of the container.
You should find yourself within the container's command prompt, where you can work on the container. Now, the container has been imported. To exit from the container, issue the command exit.
Using the export and import feature of Docker is one of the easiest ways to move a container from host to host.Enjoy moving your containers around!
Note: The docker export command does not export the contents of volumes associated with the container. If a volume is mounted on top of an existing directory in the container, docker export will export the contents of the underlying directory, not the contents of the volume.