This is an old revision of the document!
Install Docker on Linux
There are several ways to install Docker on Linux:
- 1. Via Script – Quick and easy (recommended)
- 2. Via Official Docs – Latest version with manual setup
- 3. Via Ubuntu Repo – Stable but may be outdated
1. Install Docker via Script (Recommended for Quick Setup)
This method automates the installation process using Docker’s official script. This will automatically detect your OS and install the latest version. This may not support some distro.
- Run the official install script:
curl -fsSL https://get.docker.com | sh
root@demo:~# curl -fsSL https://get.docker.com | sh # Executing docker install script, commit: ... ...
2. Install Docker via Official Documentation
For a more detailed setup, follow Docker’s official instructions.
This is the command to install Docker on Ubuntu. For installation instructions for your specific distribution, refer to the Docker documentation.
- Set up the repository:
# Add Docker's official GPG key: sudo apt-get update sudo apt-get install ca-certificates curl ...
- Install Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
3. Install Docker via Packages Repository
This method installs Docker from the distribution's package repository, which may not have the latest version, but it ensures stability.
- Update package lists:
sudo apt update
- Install Docker:
sudo apt install docker.io
- Install Docker Compose:
sudo apt install docker-compose
Post-Installation
1. Verify installation
systemctl status docker
docker --version
docker run hello-world
2. Run Docker Without 'sudo'
To allow your user to run Docker without `sudo`:
sudo usermod -aG docker $USER
Verify installation:
docker --version
docker run hello-world
3. To uninstall Docker (if needed)
sudo apt remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sudo apt autoremove