{"id":441,"date":"2026-06-17T09:33:31","date_gmt":"2026-06-17T09:33:31","guid":{"rendered":"https:\/\/virtualserversvps.com\/blog\/?p=441"},"modified":"2026-06-17T09:33:31","modified_gmt":"2026-06-17T09:33:31","slug":"setting-up-docker-on-vps-step-by-step","status":"publish","type":"post","link":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/","title":{"rendered":"Setting Up Docker on a VPS: Step-by-Step for Beginners"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Docker lets you package applications and their dependencies into lightweight, portable containers that run identically on any Linux server. Deploying Docker on a VPS gives you the isolation of virtual machines without the overhead, making it ideal for hosting multiple web apps, APIs, or databases on a single server. This guide covers installing Docker on Ubuntu 24.04, running your first container, and securing the setup for production. <a href=\"https:\/\/virtualserversvps.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Compare VPS plans on our site<\/a> to find a provider with the resources to run multiple containers smoothly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites: Minimum VPS Specs for Docker<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Docker itself is lightweight (the daemon uses ~100 MB RAM at idle), but your containers need memory too. For a typical setup hosting 3\u20135 containers:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Component<\/th><th>Minimum<\/th><th>Recommended<\/th><\/tr><\/thead><tbody><tr><td>CPU<\/td><td>1 vCPU<\/td><td>2 vCPU<\/td><\/tr><tr><td>RAM<\/td><td>1 GB<\/td><td>2\u20134 GB<\/td><\/tr><tr><td>Storage<\/td><td>20 GB<\/td><td>40 GB NVMe<\/td><\/tr><tr><td>OS<\/td><td>Ubuntu 22.04+<\/td><td>Ubuntu 24.04 LTS<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install Docker Engine<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the official Docker repository for the latest stable release. Do not use <code>apt install docker.io<\/code> \u2014 that version is often outdated:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Remove old versions (if any)\nfor pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done\n\n# Add Docker's official GPG key\nsudo apt-get update\nsudo apt-get install ca-certificates curl -y\nsudo install -m 0755 -d \/etc\/apt\/keyrings\nsudo curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg -o \/etc\/apt\/keyrings\/docker.asc\nsudo chmod a+r \/etc\/apt\/keyrings\/docker.asc\n\n# Add the repository\n# Replace \"noble\" with your Ubuntu codename if different\necho \"deb [arch=$(dpkg --print-architecture) signed-by=\/etc\/apt\/keyrings\/docker.asc] https:\/\/download.docker.com\/linux\/ubuntu $(. \/etc\/os-release &amp;&amp; echo \"$VERSION_CODENAME\") stable\" | sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null\nsudo apt-get update\n\n# Install Docker packages\nsudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the installation: <code>sudo docker run hello-world<\/code>. If you see the Hello from Docker! message, everything is working.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Run Docker Without Sudo (Post-Install)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By default, Docker requires sudo. Adding your user to the <code>docker<\/code> group eliminates this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo usermod -aG docker $USER\n# Log out and back in (or run: newgrp docker)\n# Test:\ndocker run hello-world<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Security note<\/strong>: The <code>docker<\/code> group grants root-equivalent privileges. On a multi-user VPS, consider using rootless Docker (Docker&#8217;s rootless mode) instead of the group approach.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Deploy a Real Application with Docker Compose<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Docker Compose lets you define multi-container applications in a YAML file. Here is a complete example that runs Nginx + PHP + MariaDB for a WordPress site:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># docker-compose.yml\nversion: '3.8'\n\nservices:\n  db:\n    image: mariadb:10.11\n    volumes:\n      - db_data:\/var\/lib\/mysql\n    restart: always\n    environment:\n      MYSQL_ROOT_PASSWORD: your_root_password\n      MYSQL_DATABASE: wordpress\n      MYSQL_USER: wpuser\n      MYSQL_PASSWORD: wp_password\n\n  wordpress:\n    image: wordpress:latest\n    ports:\n      - \"8080:80\"\n    restart: always\n    environment:\n      WORDPRESS_DB_HOST: db:3306\n      WORDPRESS_DB_USER: wpuser\n      WORDPRESS_DB_PASSWORD: wp_password\n      WORDPRESS_DB_NAME: wordpress\n    volumes:\n      - wp_data:\/var\/www\/html\n\nvolumes:\n  db_data:\n  wp_data:<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Deploy with: <code>docker compose up -d<\/code>. Access WordPress at <code>http:\/\/your-vps-ip:8080<\/code>. Add a reverse proxy (Nginx on the host, or another container) to serve on port 443 with SSL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Secure Docker on Your VPS<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Limit container resources<\/strong>: Use <code>--memory<\/code> and <code>--cpus<\/code> flags to prevent a single container from exhausting the host. Example: <code>docker run --memory=512m --cpus=0.5 nginx<\/code>.<\/li>\n<li><strong>Use read-only root filesystem<\/strong>: Add <code>--read-only<\/code> to containers that do not need write access to their filesystem.<\/li>\n<li><strong>Keep images updated<\/strong>: Run <code>docker pull<\/code> regularly and rebuild containers when security patches are released.<\/li>\n<li><strong>Scan images for vulnerabilities<\/strong>: <code>docker scout quickview your-image<\/code> (requires Docker Scout).<\/li>\n<li><strong>Never expose the Docker socket<\/strong> in a container unless absolutely required \u2014 it gives full host control.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Enable Log Rotation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Container logs accumulate quickly and can fill your VPS disk. Configure log rotation globally by creating or editing <code>\/etc\/docker\/daemon.json<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"log-driver\": \"json-file\",\n  \"log-opts\": {\n    \"max-size\": \"10m\",\n    \"max-file\": \"3\"\n  }\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Restart Docker: <code>sudo systemctl restart docker<\/code>. This limits each container to three 10 MB log files (30 MB max per container).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docker transforms a general-purpose VPS into a flexible application platform. Once you have the basics running, explore Docker Swarm or Kubernetes for orchestration across multiple VPS nodes. For now, start with Compose \u2014 it handles the vast majority of single-server deployments without added complexity. <a href=\"https:\/\/virtualserversvps.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Check out VPS plans on our site<\/a> to find a provider that meets your container hosting needs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker lets you package applications and their dependencies into lightweight, portable containers that run identically on any Linux server. Deploying Docker on a VPS gives you the isolation of virtual&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-441","post","type-post","status-publish","format-standard","hentry","category-vps-guides-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.1 (Yoast SEO v26.1) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Setting Up Docker on a VPS: Step-by-Step for Beginners - Virtual Servers VPS Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Setting Up Docker on a VPS: Step-by-Step for Beginners\" \/>\n<meta property=\"og:description\" content=\"Setting Up Docker on a VPS: Step-by-Step for Beginners\" \/>\n<meta property=\"og:url\" content=\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/\" \/>\n<meta property=\"og:site_name\" content=\"Virtual Servers VPS Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-17T09:33:31+00:00\" \/>\n<meta name=\"author\" content=\"Virtual-Servers-Vps-Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Virtual-Servers-Vps-Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/\",\"name\":\"Setting Up Docker on a VPS: Step-by-Step for Beginners - Virtual Servers VPS Blog\",\"isPartOf\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\"},\"datePublished\":\"2026-06-17T09:33:31+00:00\",\"author\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\"},\"breadcrumb\":{\"@id\":\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/virtualserversvps.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Setting Up Docker on a VPS: Step-by-Step for Beginners\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#website\",\"url\":\"https:\/\/virtualserversvps.com\/blog\/\",\"name\":\"Virtual Servers VPS Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0\",\"name\":\"Virtual-Servers-Vps-Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g\",\"caption\":\"Virtual-Servers-Vps-Editor\"},\"sameAs\":[\"https:\/\/virtualserversvps.com\/blog\"],\"url\":\"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Setting Up Docker on a VPS: Step-by-Step for Beginners - Virtual Servers VPS Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/","og_locale":"en_US","og_type":"article","og_title":"Setting Up Docker on a VPS: Step-by-Step for Beginners","og_description":"Setting Up Docker on a VPS: Step-by-Step for Beginners","og_url":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/","og_site_name":"Virtual Servers VPS Blog","article_published_time":"2026-06-17T09:33:31+00:00","author":"Virtual-Servers-Vps-Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Virtual-Servers-Vps-Editor","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/","url":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/","name":"Setting Up Docker on a VPS: Step-by-Step for Beginners - Virtual Servers VPS Blog","isPartOf":{"@id":"https:\/\/virtualserversvps.com\/blog\/#website"},"datePublished":"2026-06-17T09:33:31+00:00","author":{"@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0"},"breadcrumb":{"@id":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/virtualserversvps.com\/blog\/setting-up-docker-on-vps-step-by-step\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/virtualserversvps.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Setting Up Docker on a VPS: Step-by-Step for Beginners"}]},{"@type":"WebSite","@id":"https:\/\/virtualserversvps.com\/blog\/#website","url":"https:\/\/virtualserversvps.com\/blog\/","name":"Virtual Servers VPS Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/virtualserversvps.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/82a299a8284a66ff49f97c74684724a0","name":"Virtual-Servers-Vps-Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/virtualserversvps.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d820b15f1cd028e97610d9adf536df7be5cb6423869967037d468d5355fa003f?s=96&d=mm&r=g","caption":"Virtual-Servers-Vps-Editor"},"sameAs":["https:\/\/virtualserversvps.com\/blog"],"url":"https:\/\/virtualserversvps.com\/blog\/author\/virtualserversvps\/"}]}},"_links":{"self":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":1,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":442,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions\/442"}],"wp:attachment":[{"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtualserversvps.com\/blog\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}