Linux users have enjoyed running applications natively but for Windows users this has not been the case. However, beginning with Windows 10 native support of Docker has been made possible by Docker for Windows. Earlier versions, Windows 8 and 7 could not run Docker natively. Setting up Docker on Windows 7 and 8 is difficult because sometimes your hardware does not support virtualization. In this tutorial we will look at how to set up Docker on Ubuntu, Windows 10, Windows 7 and 8.
Setting up Docker on Ubuntu
Running Docker is supported on Ubuntu Xenial 16.04, Wily 15.1, Trust 14.04 and Precise 12.04. In this tutorial, we will demonstrate how to set up Docker on Xenial 16.04 using packages that are managed by Docker. You can also set up Docker using packages that are managed by Ubuntu.
To set up Docker on any version of Ubuntu it must be a 64 bit with at least version 3.10 kernel. Earlier kernel versions lack all the features required to run Docker and are prone to bugs. To check your version run the command uname -r at a terminal.
On Xenial 16.04 it is important to install linux-image-extra-* kernel packages that enable you to use aufs storage driver. A two step process of updating and installing the packages is what is required. The commands shown below accomplish that
sudo apt-get update sudo apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual
To check if you are running a 64 bit version of Ubuntu, click on system settings, then under system, click on details. Information on the system you are running will be displayed.
Once system requirements are satisfied, you can go ahead and start the process of setting up Docker.
We will install Docker from the official Docker repository instead of the Ubuntu repository to make sure we install the latest version. We need to update the package database, add a GPG key of the repository and add the repository to APT sources. The commands below will complete the set up of the repository
sudo apt-get update sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D echo "deb https://apt.dockerproject.org/repo Ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list
After our Docker repository is set up we need to update the database to reflect the added packages using this command
sudo apt-get update
Check Docker will be installed from the Docker repository and not the Ubuntu repository by running the command below. The Docker repository must be shown by the output of the command.
apt-cache policy docker-engine
After making sure Docker will be installed from the official Docker repository we are ready to install Docker. The command below will complete installation of Docker.
sudo apt-get install -y docker-engine
After the Docker installation process is complete, the daemon will start automatically and it will be set to start at boot. Check this is the situation by running this command sudo systemctl status docker. The output of the command will show you Docker is running.
Docker commands are now available, confirm this by running docker at the terminal to see the list of available commands.
To confirm you have set up Docker correctly and ready to start using it run this command docker run hello-world. A message informing you Docker is working correctly will be displayed.
There are two ways of setting up Docker on Windows. The first way is to use Docker for Windows and the second way is to use Docker tools. Docker for Windows is the most recent offering to developers working on Windows PCs. Docker for Windows runs natively on Windows using Hyper-V for virtualizing Docker engine environment and Linux-kernel features that are required by the Docker daemon. To run Docker for windows, you require a 64 bit version of Windows 10 Pro, Enterprise or Education. Presently these are the Windows versions supported but there are plans to support more Windows 10 versions. Another requirement to run Docker for Windows is that the Hyper-V package has to be enabled. The installer will automatically enable the Hyper-V package if it is not enabled.
Download a stable or beta version of Docker for windows from here https://docs.docker.com/docker-for-windows/. The stable version has been tested and it is the best option to use when you need a reliable platform. The beta version has experimental features that have not yet been fully tested. The beta version is appropriate when you would like to explore experimental features and test if they have any bugs or instability. You can only run one version of Docker for Windows at a time.
Download the installer, double click on it and follow prompts to complete installation. Once installation is complete you can run Docker commands at the terminal.
When the requirements of Windows 10 and Hyper-V are not met, you can run Docker using Docker tools. Instead of Hyper-V, Docker tools use Oracle virtual box with either 64 bit Windows 7 or 8. When you install Docker tools you have access to the tools listed below.
- The Oracle virtual box for virtualization
- The Docker Machine to help you run docker-machine commands
- The Docker engine that runs docker commands
- Docker Compose that runs docker-compose commands
- Kitematic, which is a Docker GUI
- A command line environment
Before you can install Docker tools you need to check virtualization is enabled on your machine. On windows 7, download a tool from here to check if your system supports virtualization and it is enabled. On windows 8, virtualization information is available on the performance tab of the task manager. After verifying virtualization is enabled, download and install Docker tools from here – https://www.docker.com/products/docker-toolbox.
In this tutorial, we covered setting up Docker on Ubuntu Xenial 16.04, Windows 10, 8 and 7. We discussed the prerequisites of setting up Docker on Ubuntu and demonstrated how to check if the requirements for download have been met. We demonstrated how to set up the Docker repository and install Docker. For Windows operating systems, we discussed the requirements of setting up Docker. We discussed how Docker can be set up natively on Windows 10. We also discussed how to set up Docker non natively on Windows 7 and 8.