Prerequisites
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)
Install Docker Engine
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 -yFix Docker .sock file permission issue
Verify that Docker Engine is installed correctly by running the hello-world image
This command downloads a test image and runs it in a container. When the container runs, it prints a message and exits.
Post-installation steps for Linux
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
Add your user to the docker group
Log out and log back in so that your group membership is re-evaluated
Verify that you can run docker commands without sudo
If you get /home/user/.docker/config.json: permission denied
Configure Docker to start on boot
Test the installation
Install Docker Compose
Run this command to download the current stable release of Docker Compose
Please visit Docker website to collect latest version of Docker Compose
https://docs.docker.com/compose/install
Apply executable permissions to the binary
If 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.
Optionally, install command completion for the bash and zsh shell.
Test the installation
To uninstall Docker Compose
Last updated