To install Docker on Ubuntu 20.04, you can use the following steps:
- Update the package index:
Copy codesudo apt update
- Install the packages to allow apt to use a repository over HTTPS:
Copy codesudo apt install apt-transport-https ca-certificates curl software-properties-common
- Add the Docker official GPG key:
Copy codecurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Verify the fingerprint of the key:
Copy codesudo apt-key fingerprint 0EBFCD88
- Add the Docker repository to your system:
Copy codesudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Update the package index again:
Copy codesudo apt update
- Install Docker CE:
Copy codesudo apt install docker-ce
- Start the Docker service and enable it to start at boot:
Copy codesudo systemctl start docker
sudo systemctl enable docker
You can verify that Docker is working by running the following command:
Copy codedocker run hello-world
You can also add user to the docker group
Copy codesudo usermod -aG docker $USER
and logout or restart the session to take effect the permission.