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

  1. Login via SSH:
    • Open your terminal or command prompt.
    • Use the following command to SSH into your VPS:bashCopy codessh 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:

  1. Install Required Packages:bashCopy codesudo apt install apt-transport-https ca-certificates curl software-properties-common -y
  2. Add Docker’s GPG Key:bashCopy codecurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  3. Add Docker Repository:bashCopy codesudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  4. Update Package Database:bashCopy codesudo apt update
  5. Install Docker:bashCopy codesudo apt install docker-ce -y

For CentOS:

  1. Install Required Packages:bashCopy codesudo yum install -y yum-utils device-mapper-persistent-data lvm2
  2. Add Docker Repository:bashCopy codesudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  3. Install Docker:bashCopy codesudo 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

  1. Create a Docker Group:bashCopy codesudo groupadd docker
  2. Add Your User to the Docker Group:bashCopy codesudo usermod -aG docker $USER
  3. Apply the New Group Membership:bashCopy codenewgrp docker
  4. 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:

  1. Download the Current Stable Release of Docker Compose:bashCopy codesudo 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
  2. Apply Executable Permissions to the Binary:bashCopy codesudo chmod +x /usr/local/bin/docker-compose
  3. Verify the Installation:bashCopy codedocker-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.