I have been playing around with Docker for a while now and thought it might be time to document some of this. Today we will cover off configuring a VM and installing an Operating System.

Step 1: Building the Virtual Machine

First up we need to build a VM for our platform, I have chosen Ubuntu because of its relatively up to date packages, you can use any distribution you like. If you are familiar with this process your welcome to skip on to part 2

    Build a machine with the following specs (or higher)

  • CPU: 2 x vCPUs
  • Memory: 1024mb
  • 1 x network card
  • HDD: (choose you own layout as you desire, this is what I have done)
Filesystem Type Size Mounted on
/dev/sda1 ext4 16G /
/dev/sdb1 ext4 20G /home
/dev/sdc1 ext4 9.8G /var
/dev/sdd1 ext4 20G /srv
Swap Swap 5G swap

I have chosen to break out /srv which will be used for the Docker and Gogs repositories, as well as the certificate storage for the Docker repository engine.

You have a load of choices on the VM side should you choose that or you could install to bare metal. I’ve chosen VMWare workstation as I have a long-standing history with their hypervisor, and I will be accessing it from VMWare workstation (mainly because I’m too lazy to use the web client).

Create your VM, mine is shown below

I have chosen to build a custom VM

part1_docker_auto_builder_create_vm_1

I have set the compatibility to the highest hardware compatibility available which is 11 (since I am using workstation to build it on my ESX platform.

part1_docker_auto_builder_create_vm_2

Next you will need to select Linux as your guest OS and then Ubuntu Linux (64 bit as your version

part1_docker_auto_builder_create_vm_3

Next you need to name your VM

part1_docker_auto_builder_create_vm_4

Then select whether you need a EFI or BIOS for the VM firmware, I have selected BIOS

part1_docker_auto_builder_create_vm_5

The Next step is to select the number of processors required, I would recommend at least 2 for your VM.

part1_docker_auto_builder_create_vm_6

The next step is to determine the amount of RAM required, GOGS is very light weight whilst Jenkins and Docker are load dependant. I have started out with 1GB to get going.

part1_docker_auto_builder_create_vm_7

The next step is to select your network connection

part1_docker_auto_builder_create_vm_8

Below is the default / recommended so we will go with that02

part1_docker_auto_builder_create_vm_9

Select the disk type leave this as SCSI.

part1_docker_auto_builder_create_vm_10

Then create new disk

part1_docker_auto_builder_create_vm_11

For this exercise 16GB will be fine, this will later serve as our / mount point

part1_docker_auto_builder_create_vm_12

Next provide a name.

part1_docker_auto_builder_create_vm_13

Finally, our machine customisation is finished

part1_docker_auto_builder_create_vm_14

Next edit the Virtual Machine and click Add

part1_docker_auto_builder_create_vm_15

Select Hard Disk and Next

part1_docker_auto_builder_create_vm_16

Next you need to provide a name for the disk, this field is pre-filled.

*If you are using workstation to build this on ESX there is this annoying bug where the number on the end of the name doesn’t increment with each new disk you add so you have to adjust this yourself if your adding extra disks.

part1_docker_auto_builder_create_vm_17

Repeat the above steps to add the additional drives that you require, I have stuck with thin provisioned with the exception of the drive I will be using for swap, for that drive I have pre-allocated it.

Finally, you need to configure the CD-ROM drive to point to your Ubuntu install disk, this can either be local ISO on your machine or one on the server.

part1_docker_auto_builder_create_vm_18

 

Step 2: Install Ubuntu

Now boot the new VM and the Ubuntu installer should boot.

Select your language and hit enter

part1_docker_auto_builder_install_ubuntu_1

Hit enter to begin the installation process

part1_docker_auto_builder_install_ubuntu_2

Strangely enough you need to confirm your language again

part1_docker_auto_builder_install_ubuntu_3

Next select your location

part1_docker_auto_builder_install_ubuntu_4

Now we need to determine our keyboard layout, the default is US

part1_docker_auto_builder_install_ubuntu_5

part1_docker_auto_builder_install_ubuntu_6

part1_docker_auto_builder_install_ubuntu_7

Now the system will begin to load up the networking components required for the next part of the install

part1_docker_auto_builder_install_ubuntu_8

Now a name needs to be assigned to the machine

part1_docker_auto_builder_install_ubuntu_9

You are now required to add the first user, the reason for this is in Ubuntu you are required to use a normal user account and use sudo to elevate your permissions when required.

part1_docker_auto_builder_install_ubuntu_10

part1_docker_auto_builder_install_ubuntu_11

part1_docker_auto_builder_install_ubuntu_12

part1_docker_auto_builder_install_ubuntu_13

part1_docker_auto_builder_install_ubuntu_14

The server now has enough information to move on with the setup.

part1_docker_auto_builder_install_ubuntu_15

The next step is to set the time-zone for the VM.

part1_docker_auto_builder_install_ubuntu_16

The next main step is to configure the hard disk layout

part1_docker_auto_builder_install_ubuntu_17

At this point I have selected manual configuration to allow me to configure the disks how I want them.

part1_docker_auto_builder_install_ubuntu_18

The layout you see before you now has all of your disks visible and unpartitioned. Select the first disk and press enter.

part1_docker_auto_builder_install_ubuntu_20

The installer will now ask your if you wish to create a new partition

part1_docker_auto_builder_install_ubuntu_21

After selecting yes, you will be back on the layout screen and you should notice the shiny new partition table.

part1_docker_auto_builder_install_ubuntu_22

Next you will need to create a partition on your new disk. Select the new table and then when asked select create new partition

part1_docker_auto_builder_install_ubuntu_23

I have followed normal hypervisor principles of one partition per disk, but you may choose what you will.

part1_docker_auto_builder_install_ubuntu_24

Select either primary or logical, I recommend primary.

part1_docker_auto_builder_install_ubuntu_25

Now you need to configure the file system type, by default on 16.04.1 this will be ext4, also the first partition you configure will be /.

part1_docker_auto_builder_install_ubuntu_26

Repeat the process of configuring the partitions for each of your drives including the last one where you need to set the file system type to swap or you will receive a warning about not having swap.

part1_docker_auto_builder_install_ubuntu_27

Finally, after you have selected Finish partitioning and write changes to disk the installer will ask for confirmation.

part1_docker_auto_builder_install_ubuntu_28

The installer will now go ahead and partition the disks and format them before continuing on with the install process.

part1_docker_auto_builder_install_ubuntu_29

part1_docker_auto_builder_install_ubuntu_30

Ubuntu will now confirm if you need to access the internet via a proxy, if you do please configure this below.

part1_docker_auto_builder_install_ubuntu_31

The next step in the install is to confirm whether you wish to have updates automatically installed, for play environments this is probably okay, if you are installing this as part of a business system then you will probably want to configure landscape.

part1_docker_auto_builder_install_ubuntu_32

The next step is to install additional components, I normally install the OpenSSH server here.

part1_docker_auto_builder_install_ubuntu_33

Finally, we arrive at the GRUB installer, normally in a VM environment you would just install the GRUB boot loader to the master boot record of the first disk.

part1_docker_auto_builder_install_ubuntu_34

To make life easier install the GRUB boot loader to the same disk that you put the / mount point on, usually this is going to be /dev/sda

part1_docker_auto_builder_install_ubuntu_35

part1_docker_auto_builder_install_ubuntu_36

Congratulations you have now finished installing Ubuntu and the system is now ready to reboot and start up.

part1_docker_auto_builder_install_ubuntu_37

Once booted you should see the login console as shown below.

part1_docker_auto_builder_install_ubuntu_38

To finish off the fresh install we need to ensure we are running the most update to date kernel etc.

At this point it’s worth confirming that your guest tools are reporting as running, you can check this from your hypervisor management console.

Login as your new user, mine was bob.

I recommend you modify the sources to prevent a warning failure during updates due to the CD-ROM being unmounted, to do this type the following.

sudo nano /etc/apt/sources.list

Comment out the CD-ROM entries with a #

Next, we need to update the system run the system.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get upgrade

Finally, we should configure a static IP for our new system

cd /etc/network/
sudo nano interfaces

now configure your interface similar to below ensuring it is correct for your network. Bold parts below are the parts that need adjustment.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens160
iface ens160 inet static
address 192.168.100.238/24
gateway 192.168.100.254
dns-nameservers 8.8.8.8 8.8.4.4

then save and exit and type

sudo reboot