Skip to main contentSkip to navigation
[email protected]
Client AreaSupport
Hosting Mammoth
HostingMammothYour Data, Our Responsibility
Home
Solutions
Hosting Services
Store
Pricing
About
Blog
API
Contact

Stay Ahead of the Curve

Get the latest insights on cybersecurity, AI innovations, and enterprise data solutions delivered to your inbox.

Hosting Mammoth
HostingMammothEnterprise Solutions

Enterprise-grade data solutions. Hosting, recovery, cybersecurity, and AI-powered services for businesses worldwide.

[email protected]
Sun - Fri, 9:00am - 5:00pm

Services

  • Cloud Hosting
  • Data Recovery
  • Cybersecurity
  • Legal Support
  • MSP Services
  • Web Development
  • AI Services
  • Free Server Migration

Hosting

  • VPS Hosting (NVMe SSD)
  • VDS Hosting (NVMe)
  • Storage VPS (High SSD)
  • GPU Servers
  • Managed Services
  • Cloud Firewall
  • Load Balancer
  • One-Click Apps
  • n8n Hosting
  • Object Storage
  • FAQ

Company

  • Store
  • Pricing
  • About Us
  • Locations
  • Blog
  • Testimonials
  • Contact
  • Affiliate Program
  • White-Label
  • Terms of Service
  • Privacy Policy
  • Browser Cookies
  • SLA

Support

  • Client Area
  • Submit Ticket
  • Knowledge Base
  • Server Status
  • API Documentation

© 2026 Hosting Mammoth. All rights reserved.

Knowledge Base
Getting StartedAccount ManagementVPS HostingGPU ServersStorage VPSCloud FirewallLoad BalancerServer ManagementBilling & PaymentsSupport & TicketsAffiliate ProgramReseller ProgramMarketplace & Appsn8n HostingManaged ServicesServer MigrationAPI & DevelopersSecurityTroubleshootingGlossaryInstall Guides
  1. Home
  2. /
  3. Support
  4. /
  5. Server Management
  6. /
  7. Install Docker
GUIDEServer Management

Installing Docker & Docker Compose

5 min read

Docker is a platform for building, shipping, and running applications in containers — lightweight, portable environments that include everything your application needs. Docker Compose extends Docker by letting you define and run multi-container applications with a single configuration file. This guide shows you how to install both on your Data Mammoth VPS.

Prerequisites

  • A Data Mammoth VPS running Ubuntu 22.04/24.04, Debian 12, or CentOS/AlmaLinux.
  • SSH access with sudo privileges.
  • At least 1 GB of RAM (2 GB or more recommended for production workloads).

Installing Docker on Ubuntu / Debian

Step 1 — Remove Old Versions

Remove any previously installed Docker packages:

bash
sudo apt remove docker docker-engine docker.io containerd runc 2>/dev/null

Step 2 — Install Prerequisites

bash
sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release

Step 3 — Add Docker's Official GPG Key and Repository

bash
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Add the repository (for Ubuntu):

bash
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

For Debian, replace ubuntu with debian in the URL above.

Step 4 — Install Docker Engine

bash
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 5 — Verify the Installation

bash
sudo docker run hello-world

You should see a message confirming Docker is installed correctly.

Installing Docker on CentOS / AlmaLinux

Step 1 — Remove Old Versions

bash
sudo dnf remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine 2>/dev/null

Step 2 — Add Docker Repository

bash
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Step 3 — Install Docker Engine

bash
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 4 — Start and Enable Docker

bash
sudo systemctl start docker
sudo systemctl enable docker

Step 5 — Verify

bash
sudo docker run hello-world

Post-Installation Setup

Run Docker Without Sudo

By default, Docker commands require sudo. To run Docker as a non-root user, add your user to the docker group:

bash
sudo usermod -aG docker $USER

Log out and log back in for the change to take effect. Verify:

bash
docker run hello-world

Security note: Adding a user to the docker group grants root-equivalent privileges through Docker. Only add trusted users.

Configure Docker to Start on Boot

Docker should start automatically on boot by default, but verify:

bash
sudo systemctl enable docker
sudo systemctl enable containerd

Using Docker Compose

Docker Compose is now included as a Docker plugin (no separate installation needed). Use the docker compose command (with a space, not a hyphen):

bash
docker compose version

Creating a Docker Compose File

Create a project directory and a docker-compose.yml file:

bash
mkdir ~/myapp && cd ~/myapp
nano docker-compose.yml

Example — a simple web application with a database:

yaml
version: '3.8'

services: web: image: nginx:latest ports: - "80:80" volumes: - ./html:/usr/share/nginx/html depends_on: - db restart: unless-stopped

db: image: mysql:8.0 environment: MYSQL_ROOT_PASSWORD: your_secure_password MYSQL_DATABASE: myapp MYSQL_USER: appuser MYSQL_PASSWORD: your_app_password volumes: - db_data:/var/lib/mysql restart: unless-stopped

volumes: db_data:

Basic Docker Compose Commands

bash
# Start all services in the background
docker compose up -d

View running containers

docker compose ps

View logs

docker compose logs -f

Stop all services

docker compose down

Rebuild and restart

docker compose up -d --build

Stop and remove volumes (deletes data)

docker compose down -v

Essential Docker Commands

bash
# List running containers
docker ps

List all containers (including stopped)

docker ps -a

View container logs

docker logs <container_name>

Execute a command inside a container

docker exec -it <container_name> bash

Pull an image

docker pull nginx:latest

Remove stopped containers

docker container prune

Remove unused images

docker image prune

View disk usage

docker system df

Clean up everything unused

docker system prune -a

Docker Storage and Disk Management

Docker images, containers, and volumes can consume significant disk space. Monitor usage with:

bash
docker system df

To free up space:

bash
# Remove stopped containers
docker container prune -f

Remove unused images

docker image prune -a -f

Remove unused volumes (careful — this deletes data)

docker volume prune -f

Schedule regular cleanups if you frequently build and deploy containers.

Docker Networking

Docker creates its own network bridge by default. Containers on the same Docker Compose project can communicate using service names as hostnames.

bash
# List Docker networks
docker network ls

Inspect a network

docker network inspect bridge

Security Best Practices

  • Keep Docker updated — Regularly update Docker to get security patches.
  • Use official images — Pull images from trusted sources on Docker Hub.
  • Do not run containers as root — Use the USER directive in Dockerfiles.
  • Limit container resources — Set memory and CPU limits in Docker Compose:
  • yaml
    services:
      web:
        image: nginx
        deploy:
          resources:
            limits:
              cpus: '0.5'
              memory: 512M

  • Do not expose unnecessary ports — Only map the ports your application needs.
  • Use Docker secrets — Avoid putting passwords directly in compose files for production use.
  • Firewall Configuration for Docker

    Docker modifies iptables rules directly, which can bypass UFW or firewalld. To prevent Docker from exposing ports unintentionally:

    bash
    sudo nano /etc/docker/daemon.json

    Add:

    json
    {
      "iptables": false
    }

    Restart Docker:

    bash
    sudo systemctl restart docker

    Then manually manage port access through your firewall. See Server Firewall Hardening Guide.

    What to Do Next

    • Installing n8n from the Marketplace — Deploy n8n with Docker.
    • How to Install an App on Your Server — Install marketplace apps.
    • Backup Strategy — Snapshots, Offsite, Automated — Back up your Docker volumes.
    • Monitoring Server Performance — Monitor container resource usage.

    Was this article helpful?

    ← Back to Server ManagementBrowse all categories →

    Still have questions?

    Contact Support →Submit a Ticket