-
qemu —
brew install qemu -
guestfish — https://hub.docker.com/r/curator/guestfish/
1. Backup VM
- Select VM
- Export Appliance (⌘ + E)
2. Extract files from .ova file
$ tar -xvf <file.ova>3. Convert .vmdk to .img
$ qemu-img convert -f vmdk -O raw <file.vmdk> dev-ubuntu18.img4. Create an .xz image for Docker with guestfish
- get into image
$ guestfish -a /root/$PWD/dev-ubuntu18.img --ro- run guestfish
$ ><fs> run- list filesystems
$ ><fs> list-filesystems
/dev/sda1: ext4
/dev/VolGroup/lv_root: ext4
/dev/VolGroup/lv_swap: swap- mount your *_root to /
$ ><fs> mount /dev/VolGroup/lv_root /- create an .xz image
$ ><fs> tar-out / - | xz --best >> /root/<absolute_path_to_current_directory>/dev-ubuntu18.xz- exit
$ ><fs> exit5. Import image to docker
$ cat dev-ubuntu18.xz | docker import - dev-ubuntu186. Run docker image
$ docker run -it -p 8080:80 -v ~/Projets/PlateformeDEV/:/data/apache/base/dev dev-ubuntu18 bash- params
-p: port-v: mount host folder to docker image <host_folder>:<docker_path_to_mount_to>
7. Run services
- apache
$ service apache2 startif you get this error
mktemp: failed to create directory via template `/var/lock/apache2.XXXXXXXXXX'
do that:
$ mkdir /run/lock
$ service apache2 startsource: https://askubuntu.com/a/308046
- mysql
$ service mysql start- memcached
$ service memcached start8. Commit changes to the docker image
- exit bash
$ exit- list docker containers to get the ID
$ docker ps -a- commit changes
$ docker commit <CONTAINER_ID> dev-ubuntu189. Add alias to make it simple
- add an alias to your (.zshrc|.profile|.bash_profile) file
[...]
# Docker ubuntu virtual machine
alias vm-ubuntu18="docker run -it -p 8080:80 -v ~/Projets/PlateformeDEV/:/data/apache/base/dev dev-ubuntu18 bash"
@Graywolf9 this is very experimental, I don't recommend doing that. My docker was very instable. The best way to migrate from a vm to a docker container is identifying the main cores of your server and create the container from scratch. Sorry for not answering your question.