Running CoreOS Container Linux on VirtualBox

These instructions will walk you through running Container Linux on Oracle VM VirtualBox.

Building the virtual disk

There is a script that simplifies building the VDI image. It downloads a bare-metal image, verifies it with GPG, and converts that image to a VDI image.

The script is located on GitHub. The running host must support VirtualBox tools.

As first step, you must download the script and make it executable.

wget https://raw.githubusercontent.com/coreos/scripts/master/contrib/create-coreos-vdi
chmod +x create-coreos-vdi

To run the script, you can specify a destination location and the Container Linux version.

./create-coreos-vdi -d /data/VirtualBox/Templates

Choose a channel

Choose a channel to base your disk image on. Specific versions of Container Linux can also be referenced by version number.

The Alpha channel closely tracks master and is released frequently. The newest versions of system libraries and utilities will be available for testing. The current version is Container Linux 1758.0.0.

Create a disk image from this channel by running:

./create-coreos-vdi -V alpha

The Beta channel consists of promoted Alpha releases. The current version is Container Linux 1745.1.0.

Create a disk image from this channel by running:

./create-coreos-vdi -V beta

The Stable channel should be used by production clusters. Versions of Container Linux are battle-tested within the Beta and Alpha channels before being promoted. The current version is Container Linux 1688.5.3.

Create a disk image from this channel by running:

./create-coreos-vdi -V stable

After the script has finished successfully, the Container Linux image will be available at the specified destination location or at the current location. The file name will be something like:

coreos_production_stable.vdi

Creating a config-drive

Cloud-config can be specified by attaching a config-drive with the label config-2. This is commonly done through whatever interface allows for attaching CD-ROMs or new drives.

Note that the config-drive standard was originally an OpenStack feature, which is why you'll see strings containing openstack. This filepath needs to be retained, although Container Linux supports config-drive on all platforms.

For more information on customization that can be done with cloud-config, head on over to the cloud-config guide.

You need a config-drive to configure at least one SSH key to access the virtual machine. If you are in hurry, you can create a basic config-drive with following steps:

wget https://raw.github.com/coreos/scripts/master/contrib/create-basic-configdrive
chmod +x create-basic-configdrive
./create-basic-configdrive -H my_vm01 -S ~/.ssh/id_rsa.pub

An ISO file named my_vm01.iso will be created that will configure a virtual machine to accept your SSH key and set its name to my_vm01.

Deploying a new virtual machine on VirtualBox

Use the built image as the base image. Clone that image for each new virtual machine and set the desired size.

VBoxManage clonehd coreos_production_stable.vdi my_vm01.vdi
# Resize virtual disk to 10 GB
VBoxManage modifyhd my_vm01.vdi --resize 10240

At boot time, the Container Linux will detect that the volume size has changed and will resize the filesystem accordingly.

Open VirtualBox Manager and go to Machine > New. Type the desired machine name and choose 'Linux' as the type and 'Linux 2.6 / 3.x (64 bit)' as the version.

Next, choose the desired memory size; at least 1 GB for an optimal experience.

Then, choose 'Use an existing virtual hard drive file' and find the new cloned image.

Click on the 'Create' button to create the virtual machine.

Next, go to the settings from the created virtual machine. Then click on the Storage tab and load the created config-drive into the CD/DVD drive.

Click on the 'OK' button and the virtual machine will be ready to be started.

Logging in

Networking can take a bit of time to come up under VirtualBox, and the IP is needed in order to connect to it. Press enter a few times at the login prompt to see an IP address pop up. If you see VirtualBox NAT IP 10.0.2.15, go to the virtual machine settings and click the Network tab then Port Forwarding. Add the rule "Host Port: 2222; Guest Port 22" then connect using the command ssh core@localhost -p2222.

Now, login using your private SSH key.

ssh core@192.168.56.101

Using CoreOS Container Linux

Now that the machine has booted, it is time to play around. Check out the Container Linux Quickstart guide or dig into more specific topics.