Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rudSarkar/e85af346cbbacd1cc20d752b765472fb to your computer and use it in GitHub Desktop.
Save rudSarkar/e85af346cbbacd1cc20d752b765472fb to your computer and use it in GitHub Desktop.
Docker to Virtualbox

Docker image to Virtualbox disk

https://stackoverflow.com/questions/23436613/how-can-i-convert-a-docker-image-into-a-vagrant-virtualbox-box by user blueskin (CC by-sa 3.0)


Find the size of the docker image from docker images

REPOSITORY   TAG    IMAGE ID       CREATED             SIZE
mybuntu   1.01   7c142857o35   2 weeks ago         1.94 GB

Run a container based on the image docker run mybuntu:1.01

Create a QEMU image from the container, Also, use the size of the image in the first command (seek=IMAGE_SIZE). And, for the docker export command retrieve the appropriate container id from docker ps -a

dd if=/dev/zero of=mybuntu.img bs=1 count=0 seek=2G
mkfs.ext2 -F mybuntu.img
sudo mount -o loop mybuntu.img /mnt
docker export <CONTAINER-ID> | sudo tar x -C /mnt
sudo umount /mnt

Use qemu-utils to convert to vmdk

sudo apt-get install qemu-utils qemu-img convert -f raw -O vmdk mybuntu.img mybuntu.vmdk

More info on formats that are available for conversion can be found here. https://docs.openstack.org/image-guide/convert-images.html

Now you can import the vmdk file in virtualbox


Also, https://superuser.com/a/482127/59809

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment