The truth is that big part of IT population does not clearly understand what Docker is.
I recently got a question from one of my customers, if I can perform conversion of a Docker container to a full VM. “We developed an app in Container, now we want to run it on separate VM” – he told.
I tried to explain some things, and tried to understand the reasoning behind that request, but, eventually, customer is customer and if customer asks, we need to find a solution.
To be honest, I was interested myself, if such a C2V is even possible. What tools can be used to do that?
You could think “Well, it is Linux container, so why not to install SSH inside it and just convert it using VMware converter.” I tried it actually, and of course, as I was expecting it did not work. The reason is simple: “Boot disk not found”.
If you are surprised at this point, it means you do not clearly understand how Docker works.
Some theory: Docker is a Container technology, It does not run a full blown OS inside a container, it runs only the processes application needs.
In simple words:
- Docker container does not have its own disks.
- Docker container does not have boot partition with ‘Boot loader’ inside (because it never boots)
- Docker container does not even have INIT process. The PID 1 in docker container is your own application.
OK, so what should we do, if our customer demands us to convert it to a VM?
The answer is simple, try to explain to customer, that it is not possible. Propose other options. I can even suggest some.
- Nice one: Build new VM and deploy the application inside.
- Strange one: Convert the whole Docker host together with Docker container which hosts the application.
- The Extra complex one (this is theory only, I haven’t tested it):
- Build an image file with dd command
- Create partition table in image file and write an MBR on it.
- Format partitions in image file.
- Mount image file and rsync files from Docker container to the filesystem inside.
- Mount system partitions to copied partition ( /proc, /sys, /dev, etc)
- chroot into mounted image.
- download and install Kernel and Bootloader (it may be needed to compile Kernel).
- create /etc/fstab file.
- create /etc/resolv.conf
- Convert image file to .vmdk using qemu-img.
- Create VM and configure it to use the .vmdk file from previous step.
Option 3 is basically same as building new OS and copying the app. You just build OS with your own hands (reminds me of Gentoo). It is just an interesting and complex solution which worth to be mentioned.
In conclusion I want to say, Docker has its own purpose, and if your plan is to run your application in a VM, consider migration plan in advance.
Latest posts by Aram Avetisyan (see all)
- Make Youtube Videos About Technology? Why not… The Cross-Cloud Guy - October 7, 2021
- Automating (NSX-T) REST API using Ansible URI module - December 29, 2020
- Quick Reference: Create Security Policy with Firewall Rules using NSX-T Policy API - May 4, 2020
Check “project atomic” and its result, cloud version of fedora 21. That should fully cover your customers needs.
Hello Fana,
Thanks for comment.
Indeed, Project Atomic looks promising as a Docker management system. Yes, it can automatically build VM with Docker inside.
But it still does not solve the problem I try to describe here, problem of converting Docker containers to full blown VMs.
Well, you simply cant convert container (which is basically 1 process encapsulated with its filespace) to operating system. What you can do is to give it minimal possible OS to run the container. What I was trying to say before: why would you create your own operating system (option 3 in a blog post) when there is someone who already did that job. 😉 Atomic or coreos are fine for this purpose.
Hi again Franta,
I totally agree with you, that’s why Option 3 is called “the extra complex one” It completely makes no seance to recreate OS in that way, but it is still an option
what comes to creating minimal OS to run container: Sometimes you just want to run an application on OS directly, and it makes no sense to run even minimal OS, and then run container on it. And that’s when Option 1 comes in.
What I wanted to say is that there is no definitive way or tool to convert Docker container, but there are tons of ways how to get your app to run in VM. and those are not limited to 3 options I mentioned. These 3 options are just examples to kick of the imagination.
Thanks again for sharing your thought on this.
Is it possible to convert a VMware VM running my Tomcat application to convert in to Docker instance. I have 10 legacy applications running on different VM’s, I want to run them as Docker instance. Is there tool to do V2C?
Hello Pradeep,
Thanks very much for question.
I don’t think there is such a tool, even more, I honestly don’t think it is a good idea to convert existing VM. It will for sure contain a lot of unneeded things.
I think it would be better to start with clean Docker OS image and deploy your application on it. Once you will have it done, you can export it as a ‘Docker image’, and then re-deploy it as many times as you need.
Pingback: Thevirtualist: C2V & thoughts on ‘Docker Container to VM’ conversion - How2VM