Install Docker on Ubuntu

Introduction

Docker is a container platform designed to make running and setting up applications an easy and consistent experience, regardless of which environment you are using. Docker features a rich ecosystem of container images, which are all ready for you to install and use.

Install Docker

Firstly, ensure the curl package is installed with

1user@machine:~$ sudo apt install curl

Add Docker keys and repository

Add Docker's official GPG keys for Ubuntu

1user@machine:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Then add the Docker repository

1user@machine:~$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list

Update your package list

1user@machine:~$ sudo apt update

Install the Docker package

Install the Docker package

1user@machine:~$ sudo apt install docker-ce

Add user to group

Add your user to the docker group. This will prevent the need for root privileges each time you launch a docker container.

1user@machine:~$ sudo usermod -aG docker ${USER}

Log out and back in for the new user groups to apply.

Conclusion

You have now successfully installed Docker on Ubuntu and can explore the vast Docker ecosystem. If your Docker computer has NVIDIA graphics, remember to set up the NVIDIA container toolkit with our guide: Configure docker for NVIDIA acceleration