Docker is a utility which allows a special type of virtualization. Docker allows for a program to be run “virtually” on a system by using a Docker image. An image can be downloaded or created which can then be run. Once the image is loaded and executed it is now a container. A container has allocated resources set aside for the program within the container. It is possible that a container can be nearly a whole Operating System (OS) or a single application. Changes can be made within the Docker container and saved to the Docker image. Programs outside the container cannot easily interact with the programs in the container. It is possible to have containers interact with other containers. NOTE: On the Host Operating System the Docker information is stored in ‘/var/lib/docker/’. When a container is running there is no real overhead since the Host Linux Kernel is managing the running process. It is not like the CPU, RAM and drive space overhead when running a Virtual Machine (VM). Let’s get Docker installed and I can show you the used resources of a container. Ubuntu Installation To install Docker on Ubuntu you need to be running Ubuntu 14.04, 16.04 or 18.04. If you have installed ‘docker’ or ‘docker-engine’ previously then you need to uninstall it. To uninstall the older version of Docker perform the following: Code: sudo apt remove docker docker-engine docker.io If the programs had been installed and you remove them then the files stored in ‘/var/lib/docker’ are retained. Before installing the new ‘docker-ce’ you need to verify that your kernel version is 4.x and not 3.x. Version 3 of the Linux Kernel will work, but only supports one of the two storage drivers used by Docker. NOTE: In a Terminal run ‘uname -r’ to find the currently running kernel version. To set up the pre-requisites and install Docker perform the following: Code: sudo apt update sudo apt install apt-transport-https ca-certificates curl software-properties-common sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable” After the entry is added to the repository newer systems will automatically perform an update. If your system does not perform an update automatically then you need to execute the command ‘sudo apt update’. Code: sudo apt install docker-ce CentOS/Fedora Installation To install Docker on CentOS you need a 64-bit version of CentOS 7 with the centos-extras repository enabled. To install Docker on Fedora you need a 64-bit version of Fedora 26, 27 or 28. NOTE: There are instructions to install Docker on Fedora 29, but it is not an official installation method. If either OS has had Docker installed then you need to remove the installation with the following command: Code: sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine If the programs had been installed and you remove them then the files stored in ‘/var/lib/docker’ are retained. The next step is to set up the Repository for installing Docker. In CentOS you need to perform the following commands to add the Docker Repository and install Docker: Code: sudo yum install -y yum-utils device-mapper-persistent-data lvm2 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo sudo yum install docker-ce For Fedora 26, 27 and 28 you need to add the Repository and install Docker by performing the following commands: Code: sudo dnf -y install dnf-plugins-core sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo sudo dnf install docker-ce For Fedora 29 you will need to add the repository for Fedora 28 by creating ‘/etc/yum.repos.d/docker-ce.repo’. Once created you need to add the following lines to it: Code: [docker-ce-stable] name=Docker CE Stable baseurl=https://download.docker.com/linux/fedora/28/x86_64/stable gpgkey=https://download.docker.com/linux/fedora/gpg enabled=1 gpgcheck=1 Once saved you can update the repository lists and install Docker with the commands: Code: sudo dnf update sudo dnf install docker-ce For CentOS and Fedora the Docker Daemon may not be automatically started as it is in Ubuntu. To start the Docker Daemon perform the following command: Code: sudo systemctl start docker To have the Docker Daemon start when the OS is booted you need to run the following command: Code: sudo systemctl enable docker Finishing Up the Install At this point only Root can execute Docker. To allow other users to run Docker then you need to add the users to the Docker Group. To create the Docker Group and add a user to the Docker Group you can perform the following: Code: sudo groupadd docker sudo usermod -aG docker <username> NOTE: On some installs the Docker Group may automatically created. Replace ‘<username> with the login name of the users you want to add. For Ubuntu you can also use the ‘Users and Groups’ Graphical User Interface (GUI) to perform the task. If the currently logged in user is added to the group then the user needs to log out and back in for the change to take effect. Testing Docker At this point Docker should be installed and we can easily test this by running a command: Code: docker run hello-world NOTE: If you did not add your user account to the Docker Group you will have to execute the Docker command using ‘sudo’. (Log in to hide this advertisement) The output should look similar to Figure 1. FIGURE 01 Now Docker should be running on your system. If the output does not display ‘Hello from Docker!’ in the output then you need to go back and check each step. Checking the Resources No matter your Operating System you can run Ubuntu as a Container. The command is as follows: Code: docker run -it ubuntu NOTE: The ‘-it’ parameter allows you to run the Container and allows you to interact with it. A Terminal window should open to a Ubuntu Root prompt. Perform the following commands: Code: apt update apt install htop htop A window should appear similar to Figure 2. FIGURE 02 You can see that the Container is only running a Bash shell and the ‘htop’ program. In your regular OS you can install ‘htop’ if needed and then execute it. You should see something like Figure 3. FIGURE 03 To exit the Docker window you need to exit the ‘htop’ program and then type ‘exit’ to leave the Container and be placed back into the normal Terminal window. The Container is not running a ‘Full’ version of Ubuntu as you would in a Virtual Machine or Virtualbox. I hope you can see the benefits of using Containers over a complete Virtual Operating System. You can run Docker on Windows and Mac OSX. On these Operating Systems the Docker system is emulated Linux. All calls made from the Container to the hardware must pass through a Linux Kernel. Docker will run better on a Linux system than other Operating Systems. In future articles we can cover other systems that Docker can load and even make our own.