-
Notifications
You must be signed in to change notification settings - Fork 74
Docker in XCP ng
To install the XCP-ng plugin to communicate with Docker VMs, just yum install xscontainer
(on each host).
Note: this will be probably exposed in Xen Orchestra UI in the future
There are two ways to use the newest exposed Docker features:
- Install a CoreOS VM
- Transform an existing VM in supported Docker VM
CoreOS is a Linux distribution with bundled software, like etcd, rkt, fleet etc. The ISO install CD is also using CloudInit (which is the interesting thing here).
- First thing first, create a new VM as usual, then, select the "CoreOS" template in the list and name it as you want.
- Select the CoreOS ISO as source for the installation:
- You will also notice Cloud Config panel, you'll have to uncomment the line:
# - ssh-rsa <Your public key>
And replace it with your actual SSH public key:
- ssh-rsa AAAA....kuGgQ me@mypc
- The rest of the configuration is identical to any other VM. Just click on "Create VM" and you are done:
- Your VM is now ready. Nothing else to do. You can see it thanks to the ship logo in the main view:
Now in the Xen Orchestra's VM view, you'll have a Docker panel visible.
It's empty if you don't have any Docker container running.
You should be able to access the VM with the user core and your SSH key (so no password to write!). Oh and the good news: because Xen tools are installed automatically, you already have the IP address displayed in Xen Orchetra:
So in our example (use the core user):
me@mypc $ ssh [email protected]
The authenticity of host '192.168.100.209 (192.168.100.209)' can't be established.
ED25519 key fingerprint is SHA256:NDOQgOqUm3J2ZsBEMNFCpXE1lTsu4DKqKN6H7YcxS3k.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.209' (ED25519) to the list of known hosts.
Last login: Sun Nov 22 21:00:05 2015
CoreOS stable (607.0.0)
Update Strategy: No Reboots
core@core1 ~ $
You are now connected! Let's make some tests before installing it on the disks.
core@core1 ~ $ docker run --name hello -d busybox /bin/sh -c "while true; do echo Hello World; sleep 1; done"
Unable to find image 'busybox:latest' locally
Pulling repository busybox
17583c7dd0da: Download complete
d1592a710ac3: Download complete
Status: Downloaded newer image for busybox:latest
150bc05a84971489b2dd5dc99fe0169cdbd23599d6fac55a6a8756a3c6f52853
Guess what? Check in Xen Orchestra, in the VM view, you can actually see the container running. You can now "cycle" this container: stop, pause or reboot it!
Now it works, you can make a persistent installation of your CoreOS VM. In the same SSH terminal used before, just type:
core@core1 ~ $ sudo coreos-install -d /dev/xvda -o xen -C stable
You should have this output:
Downloading the signature for http://stable.release.core-os.net/amd64-usr/607.0.0/coreos_production_xen_image.bin.bz2...
...
Downloading, writing and verifying coreos_production_xen_image.bin.bz2...
Success! CoreOS stable 607.0.0 (xen) is installed on /dev/xvda
You can reboot the VM and even eject the CoreOS ISO: it will boot as a normal VM now!
You can also use the plugin to "transform" an existing VM into a "Docker" managed one.
You need to have this installed inside the VM:
- Docker
- openssh-server
- ncat
You also have to have the Xen guest tools to be installed.
For Debian/Ubuntu like distro: apt-get install docker.io openssh-server nmap
. For RHEL and derived (CentOS...): yum install docker openssh-server nmap-ncat
.
To use Docker as non-root, please add the user you want inside the "Docker" group, eg with: sudo usermod -aG docker $(whoami)
Now, you need to access to your host (Dom0) and use the following command: xscontainer-prepare-vm -v <VM_UUID> -u <username>
Because "prepare-vm" is not exposed outside the Dom0 (yet?), we can't use Xen Orchestra to give you a one-click solution so far.
XCP-ng 🚀 Main website / Forum / Blog / Pro support