Install docker on Ubuntu 20.04 (one-click tutorial for fools)

Update the apt package index

sudo apt update

Install dependencies

sudo apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common

Add Docker's official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

After prompting OK

official installation

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

 Install the latest version of Docker Engine-Community

sudo apt install docker-ce

Now that the installation is complete, you can enter sudo docker --version or sudo docker run hello-world to test whether the installation is successful

If you want to enter docker without sudo, enter the following command directly to test it yourself:

The meaning of the following command is to add the user to the new docker group, restart the docker, and switch the current session to the new group 

sudo groupadd docker

sudo gpasswd -a ${USER} docker

sudo service docker restart

newgrp - docker

Note: The last step is necessary, otherwise, because the groups command obtains the cached group information, the newly added group information does not take effect, so there is also an error when executing docker images.

Guess you like

Origin blog.csdn.net/G_1012_/article/details/129730072