Below are the steps to install docker in ubuntu 18.04
-
First update existing packages.
$ sudo apt update ; sudo apt upgrade
-
Install utility packages
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
-
Add GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
Add docker repository to apt sources.
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
-
Update apt sources and install docker
$ sudo apt update ; sudo apt install docker-ce
-
Verify docker service is started.
$ sudo systemctl status docker
-
We need to add user to docker group to enable docker command execution without sudo user.
-
To add current user
$ sudo usermod -aG docker ${USER}
-
Alternatively to add any other user
$ sudo usermod -aG docker <username>
-
-
Verify if user is added is added to docker group by listing the groups the user is added to.
$ id -nG ${USER}
-
Logout and login to session.
su - ${USER}