├── supervisord.conf ├── phpvirtualbox.nginx.conf ├── Dockerfile ├── servers-from-env.php ├── README.md └── config.php /supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:php5-fpm] 5 | command=/usr/sbin/php5-fpm --nodaemonize 6 | 7 | [program:nginx] 8 | command=/usr/sbin/nginx -g "daemon off;" 9 | 10 | -------------------------------------------------------------------------------- /phpvirtualbox.nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | root /var/www; 4 | 5 | index index.php index.html; 6 | 7 | location / { 8 | try_files $uri $uri/ =404; 9 | } 10 | 11 | location ~ \.php$ { 12 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 13 | fastcgi_pass unix:/var/run/php5-fpm.sock; 14 | fastcgi_index index.php; 15 | include fastcgi_params; 16 | } 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | MAINTAINER Christian Lück 3 | 4 | RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y \ 5 | nginx php5-fpm supervisor \ 6 | wget unzip php5-cli 7 | 8 | # install phpvirtualbox 9 | RUN wget http://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-4.3-1.zip/download -O phpvirtualbox-4.3-1.zip 10 | RUN unzip phpvirtualbox-4.3-1.zip 11 | RUN mv phpvirtualbox-4.3-1 /var/www 12 | ADD config.php /var/www/config.php 13 | RUN chown www-data:www-data -R /var/www 14 | 15 | # add phpvirtualbox as the only nginx site 16 | ADD phpvirtualbox.nginx.conf /etc/nginx/sites-available/phpvirtualbox 17 | RUN ln -s /etc/nginx/sites-available/phpvirtualbox /etc/nginx/sites-enabled/phpvirtualbox 18 | RUN rm /etc/nginx/sites-enabled/default 19 | 20 | WORKDIR /var/www 21 | 22 | # use supervisor to monitor all services 23 | ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf 24 | 25 | # add startup script to write linked instances to server config 26 | ADD servers-from-env.php /servers-from-env.php 27 | 28 | # add empty dummy config that will be overwritten by CMD script 29 | RUN echo "" > /var/www/config-servers.php 30 | 31 | # write linked instances to config, then monitor all services 32 | CMD php /servers-from-env.php && \ 33 | supervisord -c /etc/supervisor/conf.d/supervisord.conf 34 | 35 | # expose only nginx HTTP port 36 | EXPOSE 80 37 | 38 | -------------------------------------------------------------------------------- /servers-from-env.php: -------------------------------------------------------------------------------- 1 | $value) { 8 | // ends with vboxwebsrv default port 9 | if (substr($key, -15) === '_PORT_18083_TCP') { 10 | // get prefix of key 11 | $prefix = substr($key, 0, -15); 12 | 13 | // actual readable name is stored as "/thiscontainer/givencontainer" 14 | $name = getenv($prefix . '_NAME'); 15 | $pos = strrpos($name, '/'); 16 | if ($pos !== false) { 17 | $name = substr($name, $pos + 1); 18 | } 19 | 20 | if (!$name) { 21 | $name = ucfirst(strtolower($prefix)); 22 | } 23 | 24 | $location = 'http://' . str_replace('tcp://', '', $value) . '/'; 25 | 26 | echo '- ' . $name . ' (' . $location .')' . PHP_EOL; 27 | 28 | $servers []= array( 29 | 'name' => $name, 30 | 'username' => 'username', 31 | 'password' => 'password', 32 | 'authMaster' => true, 33 | 'location' => $location 34 | ); 35 | } 36 | } 37 | 38 | if (!$servers) { 39 | echo 'Error: No vboxwebsrv instance linked? Use "--link containername:myname"' . PHP_EOL; 40 | exit(1); 41 | } 42 | 43 | $config = ' *From [the official description](http://sourceforge.net/projects/phpvirtualbox/):* 10 | 11 | An open source, AJAX implementation of the VirtualBox user interface written in PHP. 12 | As a modern web interface, it allows you to access and control remote VirtualBox instances. 13 | phpVirtualBox is designed to allow users to administer VirtualBox in a headless 14 | environment - mirroring the VirtualBox GUI through its web interface. 15 | 16 | ![](http://a.fsdn.com/con/app/proj/phpvirtualbox/screenshots/phpvb1.png) 17 | 18 | ## Usage 19 | 20 | This docker image is available as a [trusted build on the docker index](https://index.docker.io/u/clue/phpvirtualbox/). 21 | Using this image for the first time will start a download automatically. 22 | Further runs will be immediate, as the image will be cached locally. 23 | 24 | This image provides the phpVirtualBox web interface that communicates with any 25 | number of VirtualBox installations on your computers. 26 | 27 | ![](https://cloud.githubusercontent.com/assets/776829/3137332/d8500a54-e850-11e3-921d-479d43c9c80a.png) 28 | 29 | As per the above diagram the following examples assume we have two computers `PC2` and `PC3` 30 | in our cluster that we want to manage through a single installation of phpVirtualBox. 31 | 32 | Applying the same scheme to any number of computers running Virtualbox should be fairly straight forward. 33 | Also, the same scheme applies if you only want to manage a single PC, which hosts both VirtualBox and 34 | this image. 35 | 36 | Internally, the phpVirtualBox web interface communicates with each VirtualBox installation through the 37 | `vboxwebsrv` program that is installed as part of VirtualBox. 38 | So for every computer connected to the phpVirtualbox instance, we're going to use a minimal container 39 | that eases exposing the `vboxwebsrv`. 40 | 41 | For PC2: 42 | 43 | ```bash 44 | $ docker run -it --name=vb2 clue/vboxwebsrv vbox@10.1.1.2 45 | ``` 46 | 47 | And for PC3: 48 | 49 | ```bash 50 | $ docker run -it --name=vb3 clue/vboxwebsrv myuser@10.1.1.3 51 | ``` 52 | 53 | This will start an interactive container that will establish a connection to the given host. 54 | To establish an encrypted SSH connection it will likely ask for your password for each user. This is the user that runs your virtual machines (VMs). See [clue/vboxwebsrv](https://github.com/clue/docker-vboxwebsrv) for more details. 55 | 56 | > Some background: The official phpVirtualBox readme describes setting up the `vboxwebsrv` daemon so 57 | > that it is automatically started when the machine boots up and is exposed over the network. 58 | > Instead of requiring this upfront configuration, we only spawn the `vboxwebsrv` on demand 59 | > and expose its socket only through an encrypted SSH tunnel. 60 | > 61 | > In fact, if you already have your `vboxwebsrv` set up, you don't have to rely on 62 | > the clue/vboxwebrv container. In this case, you can substitute the following link by 63 | > supplying ENV variables instead. You can also pass a visual name like this: 64 | > 65 | > ```bash 66 | > -e VB3_PORT_18083_TCP=10.1.1.4:18083 -e VB3_NAME=MyServer 67 | > ``` 68 | 69 | Now that all `vboxwebsrv` instance are up, we can link everything together and start our actual phpVirtualBox container. 70 | The recommended way to run this container looks like this: 71 | 72 | ```bash 73 | $ docker run -d --link vb2:FirstPC --link vb3:MyLaptop -p 80:80 clue/phpvirtualbox 74 | ``` 75 | 76 | You can now point your webbrowser to this URL: 77 | 78 | ``` 79 | http://localhost 80 | ``` 81 | 82 | This is a rather common setup following docker's conventions: 83 | 84 | * `-d` will run a detached session running in the background 85 | * `-p {OutsidePort}:80` will bind the webserver to the given outside port 86 | * `--link {ContainerName}:{DisplayName}` links a `vboxwebsrv` instance with the given {ContainerName} and exposes it under the visual {DisplayName} 87 | * `clue/phpvirtualbox` the name of this docker image 88 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | servers = require __DIR__ . '/config-servers.php'; 14 | } 15 | 16 | /* Username / Password for system user that runs VirtualBox */ 17 | var $username = ''; 18 | var $password = ''; 19 | 20 | /* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */ 21 | var $location = 'http://127.0.0.1:18083/'; 22 | 23 | /* Default language. See languages folder for more language options. 24 | * Can also be changed in File -> Preferences -> Language in 25 | * phpVirtualBox. 26 | */ 27 | var $language = 'en'; 28 | 29 | /* Set the standard VRDE Port Number / Range, e.g. 1010-1020 or 1027 */ 30 | var $vrdeports = '9000-9100'; 31 | 32 | /* 33 | * 34 | * Not-so-common options / tweaking 35 | * 36 | */ 37 | 38 | // Multiple servers example config. Uncomment (remove /* and */) to use. 39 | // Add ALL the servers you want to use. Even if you have the server set 40 | // above. The default server will be the first one in the list. 41 | 42 | /* 43 | var $servers = array( 44 | array( 45 | 'name' => 'London', 46 | 'username' => 'user', 47 | 'password' => 'pass', 48 | 'location' => 'http://192.168.1.1:18083/', 49 | 'authMaster' => true // Use this server for authentication 50 | ), 51 | array( 52 | 'name' => '', 53 | 'username' => 'user2', 54 | 'password' => 'pass2', 55 | 'location' => 'http://192.168.1.2:18083/' 56 | ), 57 | ); 58 | */ 59 | 60 | // Disable authentication 61 | var $noAuth = true; 62 | 63 | // Host / ip to use for console connections 64 | #var $consoleHost = '192.168.1.40'; 65 | 66 | // Disable "preview" box 67 | #var $noPreview = true; 68 | 69 | // Default preview box update interval in seconds 70 | #var $previewUpdateInterval = 30; 71 | 72 | // Preview box pixel width 73 | #var $previewWidth = 180; 74 | 75 | // Max number of progress operations to keep in list 76 | var $maxProgressList = 5; 77 | 78 | // Change default preview aspect ratio to 1. 79 | // http://www.wikipedia.org/wiki/Aspect_ratio_%28image%29#Previous_and_presently_used_aspect_ratios 80 | #var $previewAspectRatio = 1.6; 81 | 82 | // Enable custom VM icons 83 | #var $enableCustomIcons = true; 84 | 85 | /* 86 | Exclusively use phpVirtualBox's groups configuration rather than VirtualBox groups. 87 | This has the following effects: 88 | 89 | *) Group changes made in phpVirtualBox will not be reflected in VirtualBox programs such as 90 | VirtualBox and VBoxManage 91 | *) Group changes will not affect which folder a VM is placed in 92 | *) You can rename groups that contain running VMs and move / copy running VMs to groups 93 | */ 94 | #var $phpVboxGroups = true; 95 | 96 | 97 | /* 98 | Allow to prompt deletion hard disk files on removal from Virtual Media Manager. 99 | If this is not set, files are always kept. If this is set, you will be PROMPTED 100 | to decide whether or not you would like to delete the hard disk file(s) when you 101 | remove a hard disk from virtual media manager. You may still choose not to delete 102 | the file when prompted. 103 | */ 104 | var $deleteOnRemove = true; 105 | 106 | /* 107 | * File / Folder browser settings 108 | */ 109 | 110 | // Restrict file types 111 | var $browserRestrictFiles = array('.iso','.vdi','.vmdk','.img','.bin','.vhd','.hdd','.ovf','.ova','.xml','.vbox','.cdr','.dmg','.ima','.dsk','.vfd'); 112 | 113 | // Restrict locations / folders 114 | #var $browserRestrictFolders = array('D:\\','C:\\Users\\Ian'); // Or something like array('/home/vbox','/var/ISOs') 115 | 116 | // Force use of local, web server based file browser instead of going through vboxwebsrv 117 | #var $browserLocal = true; 118 | 119 | // Disable file / folder browser. 120 | #var $browserDisable = true; 121 | 122 | // Disable Windows drive detection 123 | #var $noWindowsDriveList = true; 124 | 125 | // Just list all drives from C:\ - Z:\ without checking if they exist or not. 126 | // This may be required on older Windows systems with more than one drive. 127 | #var $forceWindowsAllDriveList = true; 128 | 129 | /* 130 | * Misc 131 | */ 132 | 133 | /* 134 | * Auto-refresh interval in seconds for VirtualBox host memory usage information. 135 | * Any value below 3 will be ignored. 136 | */ 137 | var $hostMemInfoRefreshInterval = 5; 138 | 139 | /* Show % of free host memory instead of % used */ 140 | #var $hostMemInfoShowFreePct = true; 141 | 142 | /* 143 | * VM Memory warnings. 144 | * 145 | * If $vmMemoryStartLimitWarn is enabled, each time a VM is started through 146 | * phpVirtualBox, it will check that the available host memory is greater than 147 | * the base and video memory of the VM + 50MB (a little bit of overhead). If it 148 | * is not, a confirmation dialog will be presented to confirm that you want to 149 | * start the VM. 150 | * 151 | * If $vmMemoryOffset is set (and $vmMemoryStartLimitWarn), $vmMemoryOffset 152 | * megabytes is subtracted from the available host memory before the check is 153 | * performed by $vmMemoryStartLimitWarn logic. For instance it may be a good 154 | * idea to always have VM memory requirements + 100MB free. 100 is the default. 155 | */ 156 | #var $vmMemoryStartLimitWarn = true; 157 | #var $vmMemoryOffset = 100; 158 | 159 | 160 | /* 161 | * Display guest additions version of a running VM on its Details tab 162 | */ 163 | #var $enableGuestAdditionsVersionDisplay = true; 164 | 165 | /* Disable any of phpVirtualBox's main tabs */ 166 | #var $disableTabVMSnapshots = true; // Snapshots tab 167 | #var $disableTabVMConsole = true; // Console tab 168 | 169 | /* Screen resolutions for console tab */ 170 | var $consoleResolutions = array('640x480','800x600','1024x768','1280x720','1440x900'); 171 | 172 | /* Console tab keyboard layout. Currently Oracle's RDP client only supports EN and DE. */ 173 | var $consoleKeyboardLayout = 'EN'; 174 | 175 | /* Max number of network cards per VM. Do not set above VirtualBox's limit (typically 8) or below 1 */ 176 | var $nicMax = 4; 177 | 178 | /* Enable advanced configuration items (normally hidden in the VirtualBox GUI) 179 | * Note that some of these items may not be translated to languages other than English. 180 | */ 181 | #var $enableAdvancedConfig = true; 182 | 183 | /* Enable startup / shutdown configuration. 184 | * This only works in linux and you must add the vboxinit file to 185 | * your startup scripts list. 186 | */ 187 | #var $startStopConfig = true; 188 | 189 | // Authentication library. 190 | var $authLib = 'Builtin'; 191 | 192 | // VM ownership 193 | #var $enforceVMOwnership = true; 194 | 195 | // Per-user VM quota 196 | #var $vmQuotaPerUser = 2; 197 | 198 | 199 | // Allow VDE network configuration. This must be supported by the underlying VirtualBox installation! 200 | // If you do not know what VDE networking is - you do not need it, it is probably not supported by your 201 | // VirtualBox installation and will cause errors if enabled. 202 | #var $enableVDE = true; 203 | 204 | // Disable setting SATA controllers port count to the max port number found when saving VMs. 205 | #var $disableSataPortCount = true; 206 | 207 | /* Enable Parallel Port configuration - EXPERIMENTAL 208 | LPT support may or may not work for you. 209 | !!! VirtualBox LPT support only works in Linux. !!! 210 | */ 211 | #var $enableLPTConfig = true; 212 | 213 | /* Enable HardDisk IgnoreFlush configuration. This controls the "ExtraData" setting 214 | * in "VBoxInternal/Devices/[controller type]/0/LUN#[x]/Config/IgnoreFlush". See 215 | * Responding to guest IDE/SATA flush requests at: 216 | * http://www.virtualbox.org/manual/ch12.html#idp12757424 217 | */ 218 | #var $enableHDFlushConfig = true; 219 | 220 | 221 | /* END SETTINGS */ 222 | 223 | 224 | } 225 | 226 | 227 | 228 | --------------------------------------------------------------------------------