The installation of docker can be done from the distribution repositories or from manually installing the packages.
First up we need to get some basic packages on our debian server as follows:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Adding the repository for the docker
Using the distribution for Docker installation.
Adding the apt-key from the trusted docker repository.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
Verify the key details using the apt-key command as follows:
root@node03:~# apt-key list docker pub rsa4096 2017-02-22 [SCEA] 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid [ unknown] Docker Release (CE deb) <[email protected]> sub rsa4096 2017-02-22 [S]
Now lets add the docker stable repo
add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable”
If you want to install the nightly package of docker then use the following command.
add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) nightly”
Now lets the install the docker package from command line.
sudo apt-get update
It is a must to run the apt-get update as we have newly added the docker repo and followit up with the installation
# apt-get install docker-ce docker-ce-cli containerd.io
Post installation Procedures on docker.
Enable the dockerd engine daemon process to auto start.
vagrant@node03:~$ sudo systemctl enable docker --now
Adding the users to docker group and modify the docker OPTS to include the docker group privileges.
vamshi@node03:~$ id uid=1000(vamshi) gid=1000(vamshi) groups=1000(vamshi),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev)
vamshi@node03:~$ grep docker /etc/group docker:x:999:
# usermod -aG dockerroot vamshi
vamshi@node03:~$ id uid=1000(vamshi) gid=1000(vamshi) groups=1000(vamshi),24(cdrom),25(floppy),29(audio),30(dip),44(video),46(plugdev),108(netdev),1001(docker)
The user is now part of the docker group and has access to the /var/run/docker.sock
vamshi@node03:~$ ls -l /var/run/docker.sock srw-rw---- 1 root docker 0 May 22 08:40 /var/run/docker.sock
The docker.sock file will be automatically updated to the root:docker owner:group permissions respectively.
And now you will be able to successfully run the docker from your user account.