Installing Docker on Your VPS: A Complete Guide
February 22, 2025 Avishka Devinda
February 22, 2025 Avishka Devinda
Docker is a powerful platform for developing, shipping, and running applications in containers. This guide will walk you through the process of installing Docker on your Virtual Private Server (VPS).
First, ensure your package index is up to date:
sudo apt update
Install packages needed to use repositories over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add Docker's official GPG key to ensure package authenticity:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to your system:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update the package index with the new Docker repository:
sudo apt update
Install the Docker engine:
sudo apt install docker-ce
Start the Docker service and enable it to start on boot:
sudo systemctl enable docker --now
Check Docker version:
sudo docker --version
Check Docker service status:
sudo systemctl status docker
To use Docker without sudo:
sudo usermod -aG docker $USER
Note: Log out and back in for this change to take effect.
List currently running containers:
docker ps
List all containers (including stopped ones):
docker ps -a
If Docker fails to start, check system logs:
sudo journalctl -u docker
If you can't connect to Docker daemon, ensure your user is in the Docker group:
groups $USER
For permission denied errors, verify Docker daemon is running:
sudo systemctl status docker
Here are some essential commands to get started:
docker pull [image-name]docker run [image-name]docker stop [container-id]docker rm [container-id]docker imagesRemember to periodically update Docker and your containers to ensure you have the latest security patches and features.