Knowledgebase

How to install Docker on a VPS (AlmaLinux)

Docker lets you run applications in isolated containers, so you can install tools like n8n, databases or Node.js apps without mixing their dependencies on your server. This guide explains how to install Docker on a VPS running AlmaLinux 8 or 9, test it, and run your first container with Docker Compose.

Important: install Docker on a clean VPS without a control panel. We do not recommend installing Docker on a server that runs cPanel/WHM, because it changes firewall and network rules that cPanel relies on. Use a separate VPS for containers.

Step 1: Remove old packages (if any)

AlmaLinux can include podman and buildah, which conflict with Docker packages. If they are installed and you do not use them, remove them:

sudo dnf remove -y podman buildah runc

Step 2: Add the Docker repository and install Docker

  1. Install the repository tool, add the official Docker CE repository, install Docker Engine with the Compose plugin, then start it:
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker

Step 3: Test the installation

sudo docker run --rm hello-world
docker --version
docker compose version

If you see "Hello from Docker!", the engine works.

Step 4: Run Docker without sudo (optional)

sudo usermod -aG docker YOUR_USER
# log out and log in again, then:
docker ps

Note: members of the docker group effectively have root access to the server. Add only trusted users.

Step 5: Run your first app with Docker Compose

  1. Create a folder and a compose.yaml file like this example, which runs Nginx:
services:
  web:
    image: nginx:stable
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:80"
    volumes:
      - ./html:/usr/share/nginx/html:ro
  1. Start it in the background and check its status and logs:
mkdir -p ~/myapp/html && cd ~/myapp
nano compose.yaml          # paste the file above
docker compose up -d
docker compose ps
docker compose logs -f web

Security tips

  • Docker publishes ports around firewalld. A port published as 8080:80 is reachable from the internet even if firewalld does not allow it. Publish ports on 127.0.0.1 as in the example, and put a reverse proxy such as Nginx in front with SSL.
  • Use official or well-known images, and pin versions instead of always pulling latest in production.
  • Store data in volumes and back them up. Removing a container does not remove its named volumes, but docker compose down -v does, so use -v only when you really want to delete the data.
  • Update images regularly: docker compose pull then docker compose up -d.

Common problems

  • "Cannot connect to the Docker daemon": the service is not running (sudo systemctl start docker), or your user is not in the docker group yet (log out and in again).
  • Package conflicts during install: remove podman/buildah/runc first as shown in Step 1.
  • The disk fills up: old images and build cache take space. Check and clean them:
docker system df
docker image prune        # removes unused (dangling) images

Frequently asked questions

How much RAM do I need for Docker?

Docker itself is light. What matters is what you run inside it. If your VPS has little memory, add swap and watch usage with docker stats.

Can I use Docker on shared hosting?

No. Docker needs root access, so you need a VPS or a dedicated server. See VPS or dedicated server: which one do you need?

Does Docker work on Ubuntu too?

Yes. Docker publishes separate instructions for Ubuntu using apt; the Docker commands after installation are the same.

Need help? Open a support ticket or message us on WhatsApp +20 127 113 3655.

  • Docker, Docker Compose, VPS, AlmaLinux, containers

Was this answer helpful?

0 Users Found This Useful