Apologies if the terminology I am using isn’t quite correct; I’m still learning about Docker…
I am looking after a series of Docker containers on two old servers that are currently running. They were created by a former employee at my organisation with docker-compose. He has since left and due to lack of documentation and missing dependencies (i.e., some of these containers were first created over 5 years ago), I am unable to re-produce the image using docker-compose.
However, the images are currently running. Is it possible to save these images and bring them back up on another server?
Assuming this advice is still valid, I have three questions:
I read elsewhere (sorry, I lost the link) that saving and loading isn’t quite the same as a virtual machine. That is, I can issue a docker commit command, but a container isn’t a VM. Changes aren’t guaranteed to be saved. I guess this is something I need to keep in mind, but it is the best that I can do.
I suppose I should stop the containers before trying to do a “save”? To not do this would save it in an inconsistent state?
Lastly, the currently running containers are using Docker versions 18.06.1 and 19.03.11 (two different servers). If I load them on a newer version of Docker (23.0.3), will there be an incompatibility problem? Do I have to load them back on the exact same Docker version?
Oh, both the servers where the containers are currently running on and the server where I intend to load the containers back on are running on Ubuntu. Two fairly old version of Ubuntu (18.04 and 20.04) and the latest LTS (22.04).
Of course I can just try to find out the above, but I wanted to see if something I’m doing is “terribly wrong” that experts might spot easily.
The link is about exporting image from a local image cache as archive file, and importing the archive file into a local image cache. It is not about containers. Generally you will want to copy the image and persistent state from volumes to the new machine and create a new container.
If you share the compose file and Dockerfile content, we can take a look what needs to be considered.
Note: from a security perspective, it is not advised to run containers based on old, unpatched images.
Regarding the compatibility: In most cases images do work with newer versions of the docker engine.
Thank you for your reply! My apologies for my mistake – clearly I was using “image” and “container” interchangeably. I see where I was wrong now. That an image runs within a container (an instance of an image, perhaps?).
Also, thank you for your kind offer! Several containers (5-10?) are involved – which is a lot of Dockerfile content to go through… But maybe one or two of them can be stopped and restarted without any noticeable impact to users. So, perhaps I will give the save/load a try and be back here with a more precise question if I encounter any problems.
I neglected to mention about my sudden concern – these containers are running on Ubuntu-based VMs that, in turn, run on a Microsoft Windows Server edition that will reach end-of-life soon. And my organisation may block network access to Windows’ versions that have reached EOL… So, even if the containers are currently running happily, I think I will need to do something about them sooner or later.
Migrating images and volume state from one host to another has another positive effect: afterward you know exactly what needs to be backed up and how it’s done.
In addition to @meyay’s powerful command to copy images to a remote server, I have a project on GitHub with some scripts and one of them is copying local volumes to remote servers.
Thank you both for your follow-ups! You’re absolutely right, @meyay – on the one hand, these containers are running fine and I don’t want to disturb them. On the other hand, we are praying every day that the host server doesn’t crash. This is obviously not a good data recovery plan! I think sooner or later, we have to take the containers down and restore them to make sure we can recover from failure.
And thanks for the GitHub link, @rimelek, and the example! I will give it a try!
Thank you both of you for your advice! I feel less worried about moving forward with this!