How to Install Docker on Your Home Server
Installing Docker on an Ubuntu server can be simplified using Docker's official convenience script. This method quickly sets up Docker without manually adding repositories or keys. Here's how you can do it:
Step 1: Update Your System
Before running the Docker installation script, ensure your system is updated. Run the following commands:
sudo apt update
sudo apt upgrade -y
This step ensures that your server has the latest security updates and system packages.
Step 2: Download and Run Docker's Installation Script
Docker provides an official script to install Docker Engine quickly. You can download and run it with a single command:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
This script will automatically detect your operating system and install the latest version of Docker, including its dependencies.
Step 3: Verify the Installation
Once the script finishes, confirm that Docker is installed by checking its version:
docker --version
You should see the installed version of Docker displayed. Additionally, verify that the Docker service is running:
sudo systemctl status docker
Step 4: Run Docker Without sudo
(Optional)
By default, Docker commands require sudo
. To run Docker as a non-root user, add your user to the docker
group:
sudo usermod -aG docker $USER
Log out and log back in to apply the changes. Test it by running:
docker run hello-world
This command downloads and runs a test container, verifying that Docker is working correctly.