Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation on a *very* simple setup #5

Open
nfarrar opened this issue May 13, 2015 · 4 comments
Open

Documentation on a *very* simple setup #5

nfarrar opened this issue May 13, 2015 · 4 comments

Comments

@nfarrar
Copy link

nfarrar commented May 13, 2015

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
Copy link
Owner

clue commented May 13, 2015

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
Copy link
Author

nfarrar commented May 13, 2015

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
Copy link
Owner

clue commented May 13, 2015

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:

  • Supply an IP to connect to. This works reasonably well for static IPs, but less so for your DHCP setup. Note however that many DHCP server have an option to reserve certain IPs for given MACs, so your IP won't necessarily have to change.
  • Supply a hostname to connect to. This requires slightly more setup to configure your DNS setup. Many DHCP servers also offer options to act as an DNS server. You could also use some DDNS provider or custom scripts to update your DNS records. If you're using a non-public DNS server, you may have to pass the --dns IP option to the container.
  • In case the container runs on the same host as your VirtualBox instance, you might be able to pass a --net=host option to the container and connect to localhost.
  • Future: We will eventually support running VirtualBox in a docker container and using simple docker links, without resorting to an SSH tunnel (Evaluate linking against containerized VirtualBox #4).

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
Copy link
Author

nfarrar commented May 14, 2015

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:

  • I'd like to make it all startup on boot, automatically - but I'm not sure if I can treat a docker container as a service and automatically start it up with init.d or upstart.
  • The way php-vboxwebsrv is starting (right now) requires manual user interaction ...
    • you have to enter the SSH password for the user
    • then you have to detach from the container (Ctrl-p Ctrl-Q)
    • i'm really hoping there's a way to get around this - if i gen an ssh cert for the vbox user, I'm not sure how to get it into the vboxwebsrv container so it can be used when authenticating to the host
  • I'm not exactly sure how the storage works. I'm assuming if I create a virtual machine using the phpvirtualbox interface running inside the docker container then that virtual machine only exists in the docker container. Being new to docker, I'm not sure if it's removed if I restart the container, or just if I remove the container - but either way, I'd like to store the virtual machines outside the container (like at /srv/virtualbox, running as an NFS share), but I'm not sure how to do this yet either. After playing around a little bit more, it appears that since virtualbox is not running in the container, it has full access to the host, and they aren't being stored inside the phpvirtualbox container. Sorry!

Do these things seem possible? Any advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants