Installing Docker on Ubuntu
Introduction
This guide explains how to install Docker on your Linux system using the official get.docker.com script. This method is quick and ensures you have the latest Docker version.
Step 1: Update System Packages
Ensure your system is up to date before proceeding:
sudo apt-get update && sudo apt-get upgrade -y
Step 2: Download and Run the Installation Script
Use the following command to download and execute the Docker installation script:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
The script detects your operating system and installs Docker accordingly.
Step 3: Verify Docker Installation
After installation, verify that Docker is installed and running:
docker --version
This should display the installed Docker version. You can also check the Docker service status:
sudo systemctl status docker
Step 4: Add Your User to the Docker Group (Optional)
By default, Docker requires root privileges. To run Docker without using sudo, add your user to the Docker group:
sudo usermod -aG docker $USER
Log out and log back in for this change to take effect, or run:
newgrp docker
Step 5: Test Docker
Run the following command to test Docker functionality:
docker run hello-world
This downloads a test image and runs it as a container. If successful, you'll see a welcome message.
Troubleshooting
If you encounter issues, try these steps:
- Ensure your user is in the Docker group if you get a permission error.
- Restart the Docker service:
sudo systemctl restart docker
sudo journalctl -u docker
Official Documentation
Docker is now installed on your system and ready for use. Refer to the Docker documentation for further guidance on managing containers, images, and services.