To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:
- Ubuntu Impish 21.10
- Ubuntu Hirsute 21.04
- Ubuntu Focal 20.04 (LTS)
- Ubuntu Bionic 18.04 (LTS)
sudo apt-get updatesudo apt-get install ca-certificates curl gnupg lsb-release -yAdd Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgUse the following command to set up the stable repository.
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 > /dev/nullInstall Docker Engine
sudo apt-get updatesudo apt-get install docker-ce docker-ce-cli containerd.io -ysudo chmod 666 /var/run/docker.socksudo docker run hello-worldThis command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.
The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The Docker daemon always runs as the root user.
If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.
Create the docker group
sudo groupadd dockerAdd your user to the docker group
sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated
newgrp dockerVerify that you can run docker commands without sudo
docker run hello-worldIf you get /home/user/.docker/config.json: permission denied
sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
sudo chmod g+rwx "$HOME/.docker" -Rsudo systemctl enable docker.service
sudo systemctl enable containerd.serviceTest the installation
docker versionRun this command to download the current stable release of Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-composePlease visit Docker website to collect latest version of Docker Compose
https://docs.docker.com/compose/install
Apply executable permissions to the binary
sudo chmod +x /usr/local/bin/docker-composeIf the command docker-compose fails after installation, check your path. You can also create a symbolic link to /usr/bin or any other directory in your path.
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-composeOptionally, install command completion for the bash and zsh shell.
sudo curl \
-L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose \
-o /etc/bash_completion.d/docker-composeTest the installation
docker-compose --versionTo uninstall Docker Compose
sudo rm /usr/local/bin/docker-compose