#Lesson Install docker and docker-compose

root

Administrator
Staff member
Bash:
# update package lists
apt-get update


# install additional packages
apt -y install ca-certificates curl gnupg lsb-release
# install and adding PGP key from Docker repository
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# adding a Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null


# update package lists
apt-get update


# if it shows an error while updating lists, enter:
apt-get install apt-transport-https

# install docker and docker-compose and additional packages
apt -y install docker-ce docker-ce-cli containerd.io docker-compose
# docker is disabled by default. turn on
systemctl start docker
# turn on startup with system
systemctl enable docker

# allow sudo access for the user
usermod -aG sudo user_name
# If you want to use docker as a user, enter
# do not forgot login into user account
su user_name
sudo groupadd docker

# add the current user to the docker group
sudo usermod -aG docker $USER
# the $USER variable means that the current user, on whose behalf the session is running,
# will be added to the docker group.

# restart docker
systemctl start docker

# check the result of docker work
docker ps
 
U

uuuuuuuuuuuuuuser

Guest
when:
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:


Bash:
    1.Create the docker group if it does not exist

$ sudo groupadd docker

    2.Add your user to the docker group.

$ sudo usermod -aG docker $USER

    3.Run the following command or Logout and login again and run (that doesnt work you may need to reboot your machine first)

$ newgrp docker

    4.Check if docker can be run without root

$ docker ps
thanks mkb
 
Top