clue / docker-phpvirtualbox

phpVirtualBox docker image, a modern webinterface mirroring the VirtualBox GUI to administer VirtualBox VMs in a headless environment
43 stars 27 forks source link

Documentation on a *very* simple setup #5

Open nfarrar opened 9 years ago

nfarrar commented 9 years ago

I'm new to docker, so I apologize if this is an ignorant question.

I've got an Ubuntu 14.04 server running virtualbox - installed directly on the host. It's mostly used in a headless state over ssh, but I'd really love to be able to remotely work with virtualbox on it via a web interface.

I installed docker and pulled down your images:

docker pull clue/docker-vboxwebsrv
docker pull clue/docker-phpvirtualbox

But I'm having trouble figuring out exactly how to get them up and running so that they're using the local virtualbox installation on the server and are accessible from another host on the network.

Again, I apologize for my lack of experience - any suggestions?

clue commented 9 years ago

I'm new to docker […]

Welcome and no worries! :) Arguably, this is one of the more complex docker setups, so let's try to clear up some things first :)

But I'm having trouble figuring out exactly how to get them up and running so that they're using the local virtualbox installation on the server and are accessible from another host on the network.

Did you follow the README? If so, are you stuck at any particular step? See also #1 which might give you some additional background information.

I understand that the setup experience might be frustrating, so please feel free to share your results and/or improvements on our setup instructions. Thanks!

nfarrar commented 9 years ago

Thanks!

TL;DR:

  1. I'm not sure how to get docker-vboxwebsrv to connect to the ssh service running on the local system with a DHCP assigned host IP (docker question).
  2. I'm not sure how to get docker-phpvirtualbox to link correctly to the locally running docker-vboxwebsrv container.

Yup, I read through both READMEs and the phpvirtualbox wiki.

The version of virtualbox I'm using is 4.3.10_Ubuntu on Ubuntu 14.04.02 desktop (with an attached monitor, but it's basement and I work on it remotely over ssh, or when necessary VNC).

I've not used vboxwebsrv or phpVirtualBox before, so I'm trying to figure out a couple things at once.

What I've done so far:

# install virtualbox
sudo vim /etc/apt/sources.list.d/virtualbox.list
Add deb http://download.virtualbox.org/virtualbox/debian saucy contrib
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install dkms unzip
sudo apt-get install virtualbox-4.3 --no-install-recommends
wget http://download.virtualbox.org/virtualbox/4.3.2/Oracle_VM_VirtualBox_Extension_Pack-4.3.2.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-4.3.2.vbox-extpack

# create vbox user & vboxusers group
sudo adduser --ingroup vboxusers vbox

# setupvbox user & group
sudo cp /etc/default/virtualbox /etc/default/virtualbox.bak
sudo bash -c 'echo VBOXWEB_USER=vbox >> /etc/default/virtualbox'

At this point the guides I've seen say to start it up with:

sudo /etc/init.d/vboxweb-service start

However, I don't have a vboxweb-service startup script - though there is a virtualbox startup script.

I ran sudo service virtualbox start, which says the kernel modules started up successfully (I'm assuming I need to do this to get vboxwebsrv running).

There is also a vboxwebsrv bin, which is a symbolic link to the shell script: /usr/share/virtualbox/VBox.sh. At this point I tried to setup and get vboxwebsrv running (without success), but then realized that docker-vboxwebsrv is supposed to do this for me (so I killed that vboxwebsrv process).

So I attempted to run:

docker run -it --name=vboxlocal clue/vboxwebsrv vbox@localhost

But I get the message:

ssh: connect to host localhost port 22: Connection refused

The machine is using DHCP (it's actually a portable server that I take to customer sites) - so it won't ever have a hardcoded IP. It looks like you can't reference localhost from inside a docker container - and the common answer is to use the hardcoded IP ... but I can't. I haven't been able to an answer to that yet, but it's a docker question, not a docker-vboxwebsrv question.

I'm assuming that (if I've got things right so far), once I have docker-vboxwebsrv running, I just need to run clue/phpvirtualbox and link it to the vboxlocal container.

It looks like I do this with something like:

docker run -d --link vboxlocal:MyComputer -p 80:80 clue/phpvirtualbox

However, since I'm running it locally, I'm not sure what the value of MyComputer should be.

clue commented 9 years ago

Thanks for your elaborate description, this certainly helps troubleshooting this.

The machine is using DHCP (it's actually a portable server that I take to customer sites) - so it won't ever have a hardcoded IP. It looks like you can't reference localhost from inside a docker container - and the common answer is to use the hardcoded IP ... but I can't. I haven't been able to an answer to that yet, but it's a docker question, not a docker-vboxwebsrv question.

Indeed, the clue/vboxwebsrv image needs to be able to connect to the PC that runs VirtualBox via SSH. There are several options:

I'm assuming that (if I've got things right so far), once I have docker-vboxwebsrv running, I just need to run clue/phpvirtualbox and link it to the vboxlocal container.

Correct. The option --link vboxlocal:MyComputer means "link the container named 'vboxlocal' with a local alias of 'MyComputer' ". The alias can be anything you want - we only use it as a display name in the phpVirtualBox's dropdown menu for available VirtualBox instances.

nfarrar commented 9 years ago

Hah! I finally got it. My biggest problem was getting vboxwebsrv running - there have been lots of changes to how it runs in the last couple versions of virtualbox. I ended up purging it and installing with:

# install virtualbox
sudo sh -c 'echo "\ndeb http://download.virtualbox.org/virtualbox/debian trusty contrib" >> /etc/apt/sources.list'
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get -y update
sudo apt-get -y install build-essential dkms virtualbox-4.3

# install the virtualbox extensions pack
wget -P /tmp http://download.virtualbox.org/virtualbox/4.3.28/Oracle_VM_VirtualBox_Extension_Pack-4.3.28-100309.vbox-extpack
sudo vboxmanage extpack install /tmp/Oracle_VM_VirtualBox_Extension_Pack-4.3.28-100309.vbox-extpack

# you can list and uninstall extpacks with the commands:
sudo vboxmanage list extpacks
sudo vboxmanage extpack uninstall "Oracle VM VirtualBox Extension Pack"

# add vbox user to vboxusers group
sudo adduser --ingroup vboxusers vbox

Then, I found that starting vboxwebsrv with --net=host got it running (no more SOAP errors), but when I attempted to link to it with docker-phpvirtualbox, I got the error:

FATA[0000] Error response from daemon: Conflicting options: --net=host can't be used with links. This would result in undefined behavior.

I found this solution though:

HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
sudo docker run -it --name=vboxwebsrv clue/vboxwebsrv vbox@$HOSTIP

... which does work. Then I was able to start up docker-phpvirtualbox with:

# startup docker-phpvirtualbox, linked to the vboxwebsrv container
sudo docker run -d --link vboxwebsrv:irbox -p 8080:80 clue/phpvirtualbox

And everything ran perfectly.

So now I'm working on a few more issues:

Do these things seem possible? Any advice?