Installing from the Docker repository

To install Docker from the official repository, follow these steps:

  1. First, we use the following command: 
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common 
  1. Then, we add the official GPG key from Docker: 
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 
  1. Set up the Docker repository using the following command: 
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" 
There are three types of update channels called the stable, nightly, and test channels. The test channel provides the prereleases that are ready for testing before availability, the nightly channel is the work in progress or beta version, and stable is the finalized bug-fixed channel. The best suggestion from the Docker team is the stable channel; however, you're free to test either channels by replacing the term stable with either nightly or test.
  1. Update the apt package index once again: 
$ sudo apt-get update
  1. Now, install the Docker package using the following command: 
$ sudo apt install docker-ce
  1. After installing via either method, you could check the versions of Docker for both types of installation using the following command: 
$ docker --version

The current version that is available in the Ubuntu repository is 17.12, while the latest release version at the time of writing this book is 18.09 (stable version).

Docker can only be run as a root user by default. Hence, add your username to the Docker group using the following command: 

$ sudo usermod -aG docker ${USER}

Ensure you reboot the system for the preceding to take effect; otherwise, you will face a permission denied error, as shown here:

Permission denied error

A quick fix to the preceding error would be to use sudo before any Docker commands.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.178