Back to articles
Security & Anti-DDoS

Advanced Docker Security: Guide to Configuring Rootless Mode on VPS to Eliminate Root Control Risks

Detailed guide on configuring Docker rootless mode on VPS to enhance security and eliminate root control risks, suitable for individual users and businesses.

DPTCloud Engineering4 min read
Advanced Docker Security: Guide to Configuring Rootless Mode on VPS to Eliminate Root Control Risks

Image credit: analogicus · Pixabay Content License

Introduction to Docker Rootless Mode

Docker is a popular tool for deploying applications in containers. However, when Docker runs with root privileges, the system is at risk of attacks from containers if not properly secured. Docker Rootless Mode allows Docker to run without root privileges, significantly reducing security risks.

In this guide, we will explore how to configure Docker rootless mode on a VPS to eliminate the risk of root control compromise and enhance system security. This guide is suitable for individual users and businesses using VPS to deploy services.

Prerequisites

  • Access to a VPS with Linux operating system (Ubuntu 20.04+ or CentOS 8+)
  • Sudo or root access on the VPS
  • Stable internet connection
  • No previously installed Docker (if present, it must be removed)

Configuring Docker Rootless Mode

We will follow these steps to configure Docker rootless mode:

Step 1: Remove Existing Docker (if any)

If you have previously installed Docker, remove it to avoid conflicts:

sudo apt remove docker docker-engine docker.io containerd runc
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd

Step 2: Install Docker Rootless Mode

Run the following commands to install Docker rootless mode:

curl -fsSL https://get.docker.com/rootless | sh

After installation, Docker will run under the current user's privileges, without requiring root access.

Step 3: Start Docker Rootless

Run the following command to start Docker rootless:

dockerd-rootless.sh --experimental --add-runtime oci-runtime=oci-runtime

To enable Docker to start automatically, add the command to ~/.bashrc or use systemd.

Step 4: Verify Configuration

Run the following command to check if Docker rootless is working:

docker info

Check the Rootless section in the output. If it shows true, Docker is running in rootless mode.

Verification and Testing

To verify that Docker rootless mode is correctly configured, perform the following steps:

  • Run docker info and check that the Rootless field is set to true.
  • Test running a simple container:
docker run --rm hello-world

If the container runs successfully without root privileges, the configuration is successful.

Troubleshooting

  • Cannot run Docker rootless: Verify that Docker rootless mode is correctly installed. Ensure no old Docker instances are running.
  • Permission errors: Ensure you are running commands under a user with access to the Docker socket.
  • Cannot connect to Docker daemon: Check if the Docker daemon is running using ps aux | grep dockerd-rootless.

References

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478