Setup Docker + Compose on Debian/Ubuntu
On this page
Isolating your apps from your main system files with headless virtual machines makes sure your host stays safe when running your own or people's code.
Getting Started
1. Install Docker + Compose
Ubuntu users can copy and paste these lines and you're good to go! Remove "sudo" if you are on Debian or logged in as root.
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg software-properties-common
curl -fsSL https://download.docker.com/linux/$(lsb_release -is | awk '{print tolower($0)}')/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/$(lsb_release -is | awk '{print tolower($0)}') $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin2. Run Docker commands without sudo
Add the current user to the docker group and relog to take effect.
sudo usermod -aG docker ${USER}
su - ${USER}Try it out
Run an example container and see if things are working.
docker compose version
docker run hello-world