rancher / old-vm

(OBSOLETE) Package and Run Virtual Machines as Docker Containers
Apache License 2.0
645 stars 133 forks source link

Document how to customize VMs via the command line #55

Open ndarilek opened 8 years ago

ndarilek commented 8 years ago

I'd like to spin up VMs with custom memory limits and disk sizes. I'm also trying to do so via the command line, or more accurately, by docker-compose. It seems like the web interface supports at least memory limits. Is this at all possible from the command line? In particular I'd like to resize my VM's disk.

Thanks.

sheng-liang commented 8 years ago

All docker command line arguments are passed to kvm command line. You can specify memory size and CPU count as follows:

docker run -e "RANCHER_VM=true" --cap-add NET_ADMIN -v \
/tmp/ranchervm:/ranchervm --device /dev/kvm:/dev/kvm \
--device /dev/net/tun:/dev/net/tun rancher/vm-rancheros -m 512m -smp 1

To change the disk size, you need to create a new VM base image that is larger. We would potentially create an option to enable the VM to mount a second disk of arbitrary size. That will require some code change in the startvm script.

ndarilek commented 8 years ago

Ah, so to resize the disk, I have to grab the original VM image, resize it and build my own image from that?

Thanks.

sheng-liang commented 8 years ago

Yes. I should have made the original qcow2 base larger. You now need to resize qcow and then resize the file system inside it. Not a trivial task.

betterclevername commented 8 years ago

Would it be possible for kvm to send keys to the guest vm? Take the docker command line arguments, feed them as keystrokes to the guest vm? Running a particular application with specified arguments within the guest vm would be useful.

Stryter commented 6 years ago

@sheng-liang I realize this project hasn't been touched in a while, but what would the amount of effort be to update this to either include an option on the command line to set the disk size or include the option on the management page?

sheng-liang commented 6 years ago

We are revamping the project now to make it work on a cluster of servers (powered by Kubernetes) and bring in many new features like clustered storage, VLAN networking, etc. Stay tuned!