Docker can be a really useful system. It can be used as a test environment, or as a way to run new services, without affecting other systems on the operating system. Unlike Windows and Mac OS, Docker for Linux is not an executable that you can just download and install. Instead there’s a repository that needs adding to apt sources. The benefit of this is that updates will come through apt the same as other systems.
Installing the Prerequisites
Before the Docker repository can be fully utilised there are a few prerequisites. Install these using the following command.
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Adding the Docker GPG key
The GPG key is needed before any Docker related systems can be installed or updated from the Docker repository.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
With the GPG key added to the system, it can be checked to make sure it is correct.
sudo apt-key fingerprint 0EBFCD88 pub rsa4096 2017-02-22 [SCEA] 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid [ unknown] Docker Release (CE deb) <firstname.lastname@example.org> sub rsa4096 2017-02-22 [S]
Adding the Repository
The repository is different depending on the version of Ubuntu installed. Install the repository with the following command:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
This command will find the version of Ubuntu installed and add the correct apt source. Once the repository added, the sources list needs to be update.
sudo apt update
With the repository installed, and the GPG key added, Docker can now be installed. There are different versions of Docker that can be installed, see the Docker documentation, however, to install the latest stable version use the following command.
sudo apt-get install docker-ce docker-ce-cli containerd.io
Once that has finished install Docker can be verified using the following:
sudo docker run hello-world
With Docker now installed. If you are wishing to use Docker without having to sudo every command you can add your user to the docker group with the following:
sudo usermod -aG docker $USER
Justin Byrne is a self motivated tech enthusiasts. Spending more than half his life dedicated to the tech industry. He built his first computer at the age of 11, and has been building ever since. His interests have changed across the years from system building to web programming and even a dab of software engineering., and just like his interests, his operating system has changed sometimes more then 4 times a year.