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.
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 infoand check that theRootlessfield is set totrue. - 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
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.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
