How to Install Docker and Run Containers on a Hosteons VPS

Docker is one of the most popular tools for deploying and managing applications in isolated environments called containers. With a Hosteons VPS, you have full root access and KVM virtualization — making it perfect for running Docker!

In this guide, we’ll show you how to install Docker on a VPS (Ubuntu/CentOS/AlmaLinux) and run your first container.


✅ Prerequisites

  • A Hosteons VPS with root access
  • OS: Ubuntu 20.04/22.04 or CentOS 7/8 / AlmaLinux 8/9
  • Updated system packages

🚀 Step 1: Update Your VPS

Ubuntu/Debian:

sudo apt update && sudo apt upgrade -y

CentOS/AlmaLinux:

sudo yum update -y
# OR
sudo dnf update -y

🚀 Step 2: Install Docker

For 

Ubuntu

:

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -y

For 

CentOS/AlmaLinux

:

sudo yum install -y yum-utils
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io -y

For AlmaLinux 8/9, replace yum with dnf where needed.


🚀 Step 3: Start and Enable Docker

sudo systemctl start docker
sudo systemctl enable docker

Check status:

sudo systemctl status docker

🚀 Step 4: Run a Test Container

Run a basic hello-world container:

sudo docker run hello-world

If everything is set up correctly, you’ll see a message from Docker saying your installation is working.


🚀 Step 5: Run Any Container (Example: NGINX)

sudo docker run -d -p 80:80 nginx

Visit your VPS IP in a browser to see the default NGINX welcome page.


⚡ Bonus Tips

  • Add your user to the docker group to avoid using sudo:
sudo usermod -aG docker $USER

Then log out and log back in.

  • You can manage Docker containers using tools like Portainer for a web UI:
sudo docker volume create portainer_data
sudo docker run -d -p 9000:9000 --name=portainer \
    --restart=always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v portainer_data:/data \
    portainer/portainer-ce

Access it at: http://your-server-ip:9000


🌐 Ready to Deploy Containers with Power?

Hosteons VPS plans provide full KVM virtualization, root access, and 10Gbps ports — ideal for Docker workloads.

👉 Order Budget VPS

👉 Order Ryzen VPS

👉 Order Ryzen VDS

Using Docker on VPS: A Beginner’s Guide

Docker on VPS

Docker is a game-changing tool for developers and system administrators. It allows you to package and run applications in isolated containers, making deployment and management seamless. Pairing Docker with a Virtual Private Server (VPS) creates a powerful environment for hosting scalable and efficient applications. This guide will help beginners get started with Docker on a VPS.


What is Docker?

Docker is a platform that uses containerization to run applications and their dependencies in a lightweight, portable environment. Containers are isolated from one another, ensuring that software runs consistently regardless of the hosting infrastructure.

Why Use Docker on a VPS?

  1. Efficient Resource Usage: Containers use less system resources than virtual machines.
  2. Consistency: Ensures your application works the same way across different environments.
  3. Scalability: Easy to scale applications by running multiple containers.
  4. Portability: Move containers between development, staging, and production with ease.

Step-by-Step Guide to Using Docker on a VPS

Step 1: Set Up Your VPS

Before installing Docker, ensure your VPS is ready.

  1. Log in to Your VPS:
   ssh username@your_server_ip
  1. Update Your VPS:
    Keep your system packages updated.
   sudo apt update && sudo apt upgrade -y

Step 2: Install Docker

Docker provides installation scripts for Linux distributions like Ubuntu, CentOS, and Debian.

  1. Install Docker on Ubuntu/Debian:
    Run the following commands:
   sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
   curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
   sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
   sudo apt update
   sudo apt install docker-ce -y
  1. Verify Installation:
    Confirm Docker is installed and running:
   docker --version
   sudo systemctl status docker
  1. Install Docker Compose (Optional):
    Docker Compose helps manage multi-container applications.
   sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
   sudo chmod +x /usr/local/bin/docker-compose

Step 3: Run Your First Docker Container

Test Docker by running a basic container.

  1. Pull a Docker Image:
    Docker uses images to create containers. Pull the official NGINX image:
   docker pull nginx
  1. Run the Container:
    Start a container using the NGINX image:
   docker run -d -p 80:80 nginx

This maps your VPS’s port 80 to the container’s port 80, making the NGINX web server accessible in your browser.

  1. Verify It’s Running:
    Visit http://your_server_ip in your browser. You should see the NGINX welcome page.

Step 4: Manage Docker Containers

Get comfortable managing containers using Docker commands:

  • List Running Containers:
  docker ps
  • Stop a Container:
  docker stop container_id
  • Remove a Container:
  docker rm container_id
  • List All Containers (Running and Stopped):
  docker ps -a

Step 5: Deploy Applications with Docker

Docker makes deploying complex applications easy.

  1. Create a Dockerfile:
    A Dockerfile specifies how a container is built. Example for a Python app:
   FROM python:3.8-slim
   WORKDIR /app
   COPY . /app
   RUN pip install -r requirements.txt
   CMD ["python", "app.py"]
  1. Build the Docker Image:
   docker build -t my-python-app .
  1. Run the Application:
   docker run -d -p 5000:5000 my-python-app

This makes your application accessible at http://your_server_ip:5000.


Best Practices for Using Docker on VPS

  1. Use Docker Compose for Multi-Container Applications:
    Define your services in a docker-compose.yml file and bring them up with:
   docker-compose up -d
  1. Monitor and Clean Up Resources:
    Docker can consume disk space quickly. Periodically clean up unused images and containers:
   docker system prune -a
  1. Use Private Repositories for Sensitive Images:
    Store proprietary Docker images securely on private registries like Docker Hub or GitHub Packages.
  2. Backup Data:
    Use Docker volumes to persist data and regularly back up critical information.

Conclusion

Docker on a VPS unlocks powerful hosting capabilities, making it easier to deploy, manage, and scale applications. With the steps outlined in this guide, you can get started with Docker and take full advantage of its features.

At Hosteons, we offer robust VPS hosting optimized for Docker, ensuring smooth performance and scalability. Explore our plans and launch your Docker-powered applications today.

Visit Hosteons.com for more information.