How to convert a Vagrant box to a Docker image -


i saw it's possible convert docker image vagrant box.

is there way convert vagrant box docker image?

i replayed ec2 boxes , virtualbox boxes in github project blacklabelops/centos. have prepared vagrantfile necessary installation , can try vagrant boxes.

ec2 boxes:

  • create , provision ami image https://github.com/katzj/ami-creator - skripts in repository.

  • afterwards use guestfish in order extract image tarball. - skripts in repository.

  • import tarball inside docker. - example in repository.

and vagrant virtualbox, commands can replayed provided vagrantfile. clone repository, spin , type:

$ qemu-img convert -f vmdk -o raw mytry-disk1.vmdk mytry.img 

the vagrant box's vmdk can found in virtualbox folder, ~/virtualbox\ vms/.

after raw has been created can apply guestfish.

$ guestfish -a mytry.img --ro $ ><fs> run 

note: tty

$ ><fs> list-filesystems  /dev/sda1: ext4 /dev/volgroup/lv_root: ext4 /dev/volgroup/lv_swap: swap $ ><fs> mount /dev/volgroup/lv_root / $ ><fs> tar-out / - | xz --best >>  mytry.xz $ ><fs> exit 

note: exiting tty

importing docker:

$ cat mytry.xz | docker import - mytryimage 

look inside container

$ docker run -it mytryimage bash 

Comments