Language & currency
Currency

Kostenlose Website & Server Migration

Oberst Server
Docker VPS - Install Docker on Ubuntu

Introduction

Docker has become one of the most popular technologies for deploying and managing applications in modern server environments. By packaging applications and their dependencies into isolated containers, Docker provides consistency across development, Testen, and production environments while minimizing resource consumption.

When combined with a Virtueller privater Server (VPS), Docker offers a powerful, flexible, and cost-effective platform for hosting websites, APIs, Datenbanken, development environments, and microservices.

This guide explains what Docker is, why it is beneficial for VPS hosting, and how to install and configure Docker on an Ubuntu VPS.

What Is Docker?

Docker is an open-source containerization platform that allows applications to run inside isolated environments known as containers.

Unlike traditional virtual machines, Docker containers do not require a separate operating system. Stattdessen, containers share the host operating system kernel while maintaining isolation between applications.

This architecture provides several advantages:

Wordpress Hosting

WordPress-Webhosting

Ab 3,99 $/Monat

Jetzt kaufen
  • Lower resource usage
  • Faster deployment
  • Consistent environments
  • Simplified application management
  • Improved scalability

How Docker Works

Docker uses several key components:

Images

Docker images serve as templates used to create containers.

An image contains:

  • Application code
  • Runtime environment
  • Libraries
  • Dependencies
  • Configuration files

Images are immutable and reusable.

Container

Containers are running instances of Docker images.

Multiple containers can run simultaneously on the same VPS without interfering with each other.

Cheap VPS

Günstiger VPS-Server

Ab 2,99 $/Monat

Jetzt kaufen

Dockerfile

A Dockerfile is a text file containing instructions used to build Docker images automatically.

Beispiel:

FROM ubuntu:24.04

RUN apt update && apt install -y nginx

CMD ["nginx", "-g", "daemon off;"]

Docker Registry

Docker registries store and distribute Docker images.

Popular registries include:

  • Docker Hub
  • GitHub Container Registry
  • Quay.io
  • Private Registries

Why Use Docker on a VPS?

Docker and VPS hosting work exceptionally well together.

Resource Efficiency

Containers consume significantly fewer resources than traditional virtual machines because they share the host operating system kernel.

Windows VPS

Windows VPS-Hosting

Fernzugriff und vollständige Verwaltung

Jetzt kaufen

Zu den Vorteilen gehören::

  • Lower memory usage
  • Reduced CPU overhead
  • Faster startup times

Application Isolation

Each application runs inside its own container.

This prevents:

  • Dependency conflicts
  • Package version conflicts
  • Application interference

Portabilität

Using the same image improves consistency, but architecture, kernel features, storage and configuration can still change behavior.

You can build a container on your development machine and deploy the exact same container to production.

Skalierbarkeit

Containers can be replicated quickly to handle increased traffic or workloads.

This is particularly useful for:

  • APIs
  • SaaS-Anwendungen
  • Web applications
  • Microservices

Simplified Deployment

Applications can be deployed with a single command rather than manually installing software and dependencies.

Common Docker VPS Use Cases

Docker is widely used for:

Website Hosting

Examples:

  • WordPress
  • Joomla
  • Drupal
  • Laravel

Development Environments

Developers can maintain isolated environments for:

  • PHP
  • Python
  • Node.js
  • Go
  • Java

Datenbanken

Popular database containers include:

  • MySQL
  • MariaDB
  • PostgreSQL
  • MongoDB
  • Redis

Reverse Proxies

Examples:

  • Nginx
  • Traefik
  • HAProxy

Self-Hosted Applications

Examples:

  • Nextcloud
  • Mastodon
  • Open WebUI
  • LibreChat
  • GitLab

Voraussetzungen

These commands target a fresh, supported Ubuntu VPS. If Docker or containerd is already installed, review package conflicts and preserve existing workloads before changing repositories. Run Docker commands with sudo until you deliberately grant Docker-group access.

Before installing Docker, ensure your VPS meets the following requirements.

Operating System

Recommended:

  • Ubuntu 22.04 LTS
  • Ubuntu 24.04 LTS

Other distributions require their own installation instructions; examples include:

  • AlmaLinux
  • Rockiges Linux
  • Debian
  • Fedora

Root or Sudo Access

Verify access:

sudo whoami

Expected output:

root

Update Existing Packages

Update the operating system before installation:

sudo apt update
sudo apt upgrade -y

Installing Docker on Ubuntu

Schritt 1: Install Required Dependencies

Install prerequisite packages:

sudo apt install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
gnupg \
lsb-release -y

Schritt 2: Add Docker’s Official GPG Key

Download and install the Docker repository signing key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg

Verifizieren:

ls -l /usr/share/keyrings/docker.gpg

Schritt 3: Add Docker Repository

Add Docker’s official repository:

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

Update package lists:

sudo apt update

Schritt 4: Install Docker Engine

Install Docker:

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

Schritt 5: Verify Docker Installation

Check Docker version:

docker --version

Example output:

Docker version <installed-version>

Verify service status:

sudo systemctl status docker

Expected output:

active (running)

Schritt 6: Enable Docker at Boot

Enable automatic startup:

sudo systemctl enable docker

Verifizieren:

sudo systemctl is-enabled docker

Expected output:

enabled

Running Your First Docker Container

Docker provides a simple test image.

Laufen:

sudo docker run --rm hello-world

Successful output confirms:

  • Docker Engine is working
  • Container downloads function correctly
  • Network connectivity is operational

Running an Nginx Container

Launch a web server:

docker run -d \
--name nginx \
-p 80:80 \
nginx

Verify running containers:

docker ps

Open your browser:

http://SERVER-IP

The Nginx welcome page should appear.

Running Docker Without Root

Membership in the docker group effectively grants root-level control of this server; only trusted administrators should receive it. This is different from Docker rootless mode.

By default, Docker requires root privileges.

Add your user to the Docker group:

sudo usermod -aG docker $USER

Apply changes:

newgrp docker

Verifizieren:

docker ps

If no sudo is required, configuration is successful.

Basic Docker Commands

List Running Containers

docker ps

List All Containers

docker ps -a

View Images

docker images

Stop Container

docker stop container_name

Start Container

docker start container_name

Restart Container

docker restart container_name

Remove Container

docker rm container_name

Remove Image

docker rmi image_name

Installing Docker Compose

Modern Docker installations include Docker Compose as a plugin.

Verifizieren:

docker compose version

Example output:

Docker Compose version v2.x.x

Creating Your First Docker Compose Project

Remove the earlier demonstration NGINX container first if it still uses port 80 or the name nginx. For real applications, use persistent volumes, versioned image tags and tested Backups before replacing containers.

Create a project directory:

mkdir docker-test
cd docker-test

Create:

nano compose.yml

Beispiel:

services:
  nginx:
    image: nginx
    container_name: nginx
    ports:
      - "80:80"

Start:

docker compose up -d

Verifizieren:

docker compose ps

Stop:

docker compose down

Managing Container Logs

View logs:

docker logs container_name

Follow logs in real time:

docker logs -f container_name

This is particularly useful when troubleshooting applications.

Updating Docker Containers

Pull latest image:

docker pull nginx

Stop container:

docker stop nginx

Remove container:

docker rm nginx

Create new container using the updated image.

Docker Security Best Practices

Published ports can bypass normal UFW filtering because Docker manages its own network rules. Restrict access using Docker-compatible filtering or an upstream firewall and bind private services to localhost or a protected interface. Never expose the unauthenticated Docker API.

Use Trusted Images

Prefer official images from trusted registries.

Beispiel:

nginx
mariadb
redis
ubuntu

Avoid Running as Root

Configure applications to run as non-root users whenever possible.

Keep Docker Updated

Update regularly:

sudo apt update
sudo apt upgrade

Limit Resource Usage

Beispiel:

docker run \
--memory=512m \
--cpus=1 \
nginx

This prevents a container from consuming excessive resources.

Remove Unused Objects

Cleanup unused resources:

docker system prune -a

Review carefully before confirming.

Common Docker Troubleshooting

Docker Service Not Running

Start manually:

sudo systemctl start docker

Permission Denied

Verify group membership:

groups

Ensure:

docker

appears in the output.

Port Already in Use

Check listening services:

ss -tulpn

Modify Docker port mapping if necessary:

docker run -p 8080:80 nginx

Container Exits Immediately

Inspect logs:

docker logs container_name

Most startup issues can be identified through log analysis.

Docker vs Virtual Machines

Besonderheit Docker Containers Virtual Machines
Startup Time Seconds Minutes
Resource Usage Niedrig Hoch
Guest OS Not Required Required
Leistung Near Native Slight Overhead
Skalierbarkeit Exzellent Mäßig

Containers are ideal for application deployment, while virtual machines remain useful when complete operating system isolation is required.

Letzte Gedanken

Docker transforms a VPS into a flexible application hosting platform capable of running websites, APIs, Datenbanken, development environments, and enterprise applications with minimal overhead. Its lightweight architecture, portability, and scalability make it one of the most valuable tools available to modern system administrators and developers.

By installing Docker on your VPS and learning the basics of container management, you gain a powerful foundation for deploying reliable, sicher, and highly portable applications across virtually any environment.

Teilen Sie diesen Beitrag

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert