The Difference: Docker vs. Virtualization

Technical Basics

Docker is an open source container technology that became immensely popular in 2014. Docker itself is written in Google’s programming language Go and supported on all major Linux distributions (RedHat, CentOS, Oracle Linux, Ubuntu etc.). The technical underpinnings are not completely new, Docker leverages Linux kernel features for containers such as cgroups and namespaces. So even though Docker itself is relatively new, the underlying container technology is an established technology. Docker containers run on top of an operating system.

It is reported that Google starts 2 000 000 000 every week for search, mail, etc.

Virtualization versus Container

It’s important to distinguish Linux containers and Docker from traditional and more common type 1 or type 2 hypervisors. Type 1 hypervisors provide server virtualization with different operating systems on bare metal hardware, whereas Type 2 hypervisors often provide desktop virtualization based on an existing operating system as shown below.

Screen Shot 2015-09-21 at 10.44.55

 

In contrast to popular virtualization technologies, Docker containers run the host’s Linux kernel. Docker is about isolation, not about virtualization. The required time to startup a container is only in the range of milliseconds. Still containers have their own incremental files system, where layers are reused across containers. In addition, every container has its own network stack, therefore its own IP-address, and its own process space.

Extend a CentOS Oracle VirtualBox Image with more Disk Space

virtualbox logoUPDATE: A lot has change over the years. I post a lot on medium now (bookmark it here, no excuse!). Also I have 80+ free webcasts on youtube (make sure to subscribe). Then all my slides went to speakerdeck. Yes. A lot is about THE cloud these days :-). For news: twitter.

This started as a simple note to myself. Hopefully good enough for me to reuse it one day. Over time it turned into a post that made a lot of people happy (see comments section) because it really sucks when you run out of disk space in a VirtualBox.

So the following instructions will probably only give you a rough idea if you found this page looking for help on Google.

Anyway, these steps worked fine for me. What a bliss not having the file systems 98% full when starting a project. Somehow, I always run out of disk space when I install SOA Suite. No matter how big I initially size it.

The challenge certainly is to get VBoxManage, fdisk and lvm right without completely messing up your system.

Warning!

fdisk and to a lesser extend lvm are razor sharp tools that can easily cause bleeding wounds. So make sure you have a backup (<- repeat this last sentence after me).

On Host side (e.g. Windows 7 here)

VBox instance has to be shut down for the following steps.

Extend the VBox image

Run the from the command line on the host system. Specify the new size in MB.

Example 1 with host system windows:

C:\Users\frank>"\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd --resize 29696 "\01_work\30 vms\virt
box\CentOS 6.4 64b STUDENT\CentOS 6.4 64b STUDENT.vdi"

Example 2 with host system MacOS:

# change to dir with vbox-manage
$ cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS
$ VBoxManage modifyhd --resize 55000 /Users/frank/Virtual\ Boxes/ProjectA/project-disk1.vdi

On Guest side (e.g. CentOS 6.4 here)

Stay calm

Double check that you are on the guest side. Runing fdisk accidentially on the host side can destroy your whole computer, whereas running it on the guest side typically reduces the risk to destroy your virtual image only.

Note that this is not a kindergarten party, you have to run the commands with root privileges.

fdisk

Use fdisk -l to list devices, then e.g. fdisk /dev/sda to add another primary partition (command n), next free number (e.g. 3), of type 8e (Linux LVM) (t), print part table (p), write table (w). Reboot…

Add new partition as physical volume (PV)

[root@ccloud12 ~]# lvm

lvm> pvcreate /dev/sda3
 Physical volume "/dev/sda3" successfully created

Extend existing volume group (VG)

lvm> vgextend vg_ccloud12 /dev/sda3
 Volume group "vg_ccloud12" successfully extended

Find out partition name

lvm> lvdisplay
 --- Logical volume ---
 LV Path /dev/vg_ccloud12/lv_root

Extend logical volume

lvm> lvextend -L+8.48G /dev/vg_ccloud12/lv_root
 Rounding size to boundary between physical extents: 8.48 GiB
 Extending logical volume lv_root to 25.56 GiB
 Logical volume lv_root successfully resized

Resize the File System (Guest System)

resize2fs -F /dev/vg_ccloud12/lv_root

That’s it

Try df -h and enjoy your new diskpace.

Let me know if you had any success eg. using Oracle Enterprise Linux. Any super secret tips how to improve or shorten this are welcome!

Note: now I am using Mac OS as a host system, it works the same way.

Make VirtualBox Shared Folder Mount read / write for a non-root User

This is just a note to myself. The command adds user oracle to the vboxsf  group. Don’t even try chmod or chown on the mount point, it won’t help. Replace oracle with your own uid.

sudo usermod -a -G vboxsf oracle