Docker is an open-source project that provides an open platform for developers and sysadmins to build, package, and run applications anywhere as a lightweight container. Docker automates the deployment of applications inside software containers.Docker is a great tool for developers. The key reason why is that it removes friction incurred when setting up your development laptop for different development environments, especially for Polyglot developers!.
In this post we’ll go through the basics of installing and getting up and running with Docker on a your Ubuntu Desktop to start developing with Docker
If you’re a developer who supports many different projects, all written in different programming languages, using different runtime libraries and frameworks in those languages. For instance, PHP websites developed using Laravel, others using CakePHP, yet others using the YII Framework and then there are a few WordPress based websites. All using slightly different versions of the Frameworks because customers don’t want to upgrade for a variety of different reasons.
It can be an absolute nightmare configuring your workstation just to fix a 5-minute bug. It can take hours uninstalling tweaking, troubleshooting and reconfiguring. Time which is better spent hyping some Web Framework on Twitter!
Docker to the rescue
Docker drastically simplifies this process. Reducing the need for developers to be configuration experts enabling them to focus on solving problems using code!
If you’re running Mac or Windows installing Docker is a relatively simple process of quite literally following a wizard. Read instructions on how to install docker on Windows or install docker on Mac OSX. You should be up and running is minutes.
Installing docker on ubuntu
When it comes to installing Docker on Ubuntu, things are slightly trickier, and although the instructions on the docker website are great and will get you up and running quickly. I have found a couple of quirks that aren’t always that obvious. I will aim to cover these and keep this post updated as I find them.
Don’t install docker from the default Ubuntu repositories
How to uninstall old versions of docker
There are a number of different versions of docker available. As with any Open Source library, they tend to go through different iterations before finally getting to a state where they either get funding and are able to market the product and get it ready for the market or they subject to the whims and desires or whoever maintains them or they just die!
Fortunately for docker, it gained mass appeal and adoption. Unfortunately, most package repositories still have the much older versions of a package available for public download, and a number of tutorials on the internet provide guides and tutorials for installing these older versions.
So firstly, check whether you have any older versions installed. ( Open a terminal window
ctrl + alt + t ).
docker -v if the terminal responds with a version number lower than
Docker version 17.05.0-ce, build 89658be you need to remove it.
If you have a higher version or build then you’re good to go.
dpkg -l | grep -i docker to identify the version, this should return with either :
Remove older versions of docker
The completely remove and purge the package replacing
[package name] with the name of the package you have installed :
Install Docker from the Docker Repository
Once you have completed removing or ensuring you don’t have any older versions installed on your development machine, then you should be ready to install Docker Community edition .
The instructions below are reproduced from the Official Docker Website, but please be advised these may change and we urge you to double-check on the docker website.
There is a complete script to automate the installation of docker available from https://get.docker.com/ you can download this script and run it on your machine.
Please be aware that this install process is typical for 64-Bit laptops or desktops using Ubuntu 16.04 LTS.
Check the docker website for other configuration options
After completing the steps above you should Log out and log back into your laptop for the settings to take effect.
Run your first docker images
You should now be in state to start playing and learning how to use docker.
There are three ways to test if docker is working.
1. Hello World
In typical programmer tradition we’ll run a “Hello World” application docker style.
To run the Hello-World sample, open a terminal window
ctrl + alt + t
docker run hello-world you should see a response similar to;
2. Busy Box
We’ll run a small embedded Linux distro called :
BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU
fileutils, shellutils etc.
The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.
To run an instance of Busybox, open a terminal window. (
ctrl + alt + t )
docker run busybox echo "hello from threenine.co.uk" and you should see a result similar to:
If you’re feeling a little more adventurous you can use the docker client to search for an image and run it. As an example, from the terminal use this
docker search threenine should return a list of the docker images we have created.
At the time writing this post, it returns a list of 4 images, of which the specific one of interest will be,
threenine/docker-whale which is a result of following the docker tutorial for creating images.
Let’s go ahead and run that image
docker run threenine/docker-whale
Docker should now be installed on your development machine and you should now be able to create and use docker images. Docker will help to simplify common development configuration scenarios and help to isolate specific configurations to containerised machines.
Docker can be used in a wide variety of environments, the requirements of the infrastructure are no longer linked with the environment of the application.
A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Latest posts by Gary Woodfine (see all)
- How to run PHP Server with BrowserSync and Gulp - September 2, 2018
- How to change WordPress User Password in phpMYAdmin - July 28, 2018
- 8 Plugins you need for your WordPress Website 2018 - July 1, 2018