Installing and setting up Docker on a Cloudnium.net KVM VPS involves several steps. Here’s a comprehensive guide to help you through the process:
1. Access Your VPS
- Login via SSH:
- Open your terminal or command prompt.
- Use the following command to SSH into your VPS:bashCopy code
ssh root@your_vps_ip
- Replace
your_vps_ip
with the actual IP address of your VPS.
2. Update Your System
Before installing Docker, ensure your system is up-to-date:
bashCopy codesudo apt update
sudo apt upgrade -y
3. Install Docker
For Ubuntu:
- Install Required Packages:bashCopy code
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
- Add Docker’s GPG Key:bashCopy code
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add Docker Repository:bashCopy code
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Update Package Database:bashCopy code
sudo apt update
- Install Docker:bashCopy code
sudo apt install docker-ce -y
For CentOS:
- Install Required Packages:bashCopy code
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
- Add Docker Repository:bashCopy code
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- Install Docker:bashCopy code
sudo yum install -y docker-ce
4. Start and Enable Docker
After installation, start the Docker service and enable it to run on boot:
bashCopy codesudo systemctl start docker
sudo systemctl enable docker
5. Verify Docker Installation
To verify that Docker is installed correctly and running, use the following command:
bashCopy codesudo docker run hello-world
This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message.
6. Optional: Manage Docker as a Non-root User
- Create a Docker Group:bashCopy code
sudo groupadd docker
- Add Your User to the Docker Group:bashCopy code
sudo usermod -aG docker $USER
- Apply the New Group Membership:bashCopy code
newgrp docker
- Verify Docker Command Without
sudo
:bashCopy codedocker run hello-world
7. Setting Up Docker Compose (Optional)
Docker Compose is a tool for defining and running multi-container Docker applications. To install Docker Compose, follow these steps:
- Download the Current Stable Release of Docker Compose:bashCopy code
sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*\d')" /usr/local/bin/docker-compose
- Apply Executable Permissions to the Binary:bashCopy code
sudo chmod +x /usr/local/bin/docker-compose
- Verify the Installation:bashCopy code
docker-compose --version
Conclusion
You have now installed and set up Docker on your Cloudnium.net KVM VPS. You can start deploying containers and building your applications using Docker. If you run into any issues, consult the official Docker documentation or reach out to the Docker community for support.