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)
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
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.
Next you will need to select Linux as your guest OS and then Ubuntu Linux (64 bit as your version
Next you need to name your VM
Then select whether you need a EFI or BIOS for the VM firmware, I have selected BIOS
The Next step is to select the number of processors required, I would recommend at least 2 for your VM.
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.
The next step is to select your network connection
Below is the default / recommended so we will go with that02
Select the disk type leave this as SCSI.
Then create new disk
For this exercise 16GB will be fine, this will later serve as our / mount point
Next provide a name.
Finally, our machine customisation is finished
Next edit the Virtual Machine and click Add
Select Hard Disk and Next
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.
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.
Step 2: Install Ubuntu
Now boot the new VM and the Ubuntu installer should boot.
Select your language and hit enter
Hit enter to begin the installation process
Strangely enough you need to confirm your language again
Next select your location
Now we need to determine our keyboard layout, the default is US
Now the system will begin to load up the networking components required for the next part of the install
Now a name needs to be assigned to the machine
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.
The server now has enough information to move on with the setup.
The next step is to set the time-zone for the VM.
The next main step is to configure the hard disk layout
At this point I have selected manual configuration to allow me to configure the disks how I want them.
The layout you see before you now has all of your disks visible and unpartitioned. Select the first disk and press enter.
The installer will now ask your if you wish to create a new partition
After selecting yes, you will be back on the layout screen and you should notice the shiny new partition table.
Next you will need to create a partition on your new disk. Select the new table and then when asked select create new partition
I have followed normal hypervisor principles of one partition per disk, but you may choose what you will.
Select either primary or logical, I recommend primary.
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 /.
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.
Finally, after you have selected Finish partitioning and write changes to disk the installer will ask for confirmation.
The installer will now go ahead and partition the disks and format them before continuing on with the install process.
Ubuntu will now confirm if you need to access the internet via a proxy, if you do please configure this below.
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.
The next step is to install additional components, I normally install the OpenSSH server here.
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.
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
Congratulations you have now finished installing Ubuntu and the system is now ready to reboot and start up.
Once booted you should see the login console as shown below.
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
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).
# The loopback network interface
iface lo inet loopback
# The primary network interface
iface ens160 inet static
dns-nameservers 188.8.131.52 184.108.40.206
then save and exit and type