Thursday, July 2, 2020

Docker installation on Ubuntu


 1979  sudo apt-get update
 1980  sudo apt-get install     apt-transport-https     ca-certificates     curl     gnupg-agent     software-properties-common
 1981  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 1984  sudo apt-key fingerprint 0EBFCD88
 1985  sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
 1986     $(lsb_release -cs) \
 1987     stable"
 1988  sudo apt-get update
 1989  sudo apt-get install docker-ce docker-ce-cli containerd.io
 1990  docker -v
 1991  docker run hello-world
 1992  sudo docker run hello-world

 1995  sudo groupadd docker
 1996  echo ${USER}
 1997  sudo gpasswd -a $USER docker


Manage Docker as a non-root user
The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user.
If you don’t want to use sudo when you use the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

  • Add the docker group if it doesn't already exist:
     sudo groupadd docker
    
  • Add the connected user "$USER" to the docker group. Change the user name to match your preferred user if you do not want to use your current user:
     sudo gpasswd -a $USER docker
    
  • Either do a newgrp docker or log out/in to activate the changes to groups.
  • You can use
     docker run hello-world
    
    to check if you can run docker without sudo.

No comments:

Post a Comment