Wednesday, 14 December 2016

Import VM into Docker

A docker image is roughly a tarred filesystem with some additional metadata. Docker even allows to create images directly from tarballs with docker import, so if you can put all the filesystem of your VM in a tar, you can convert it to a docker image. And then you can try to run the image with the init process used by your VM as command.
Importing a VM into Docker is not the intended way to create images, it is possible and can provide you with a fast starting point to test things before you fully commit. To do this, you simply provision a linux root file system (in your case: your CentOS VM) and stream it into docker import like so:
tar -cC [folder containing provisioned root fs] . | docker import - [image name]
Docker's base image documentation has more info and even links to a script to create a CentOS base image.

No comments:

Post a Comment