{"id":16179,"date":"2019-03-25T12:13:37","date_gmt":"2019-03-25T12:13:37","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=16179"},"modified":"2026-03-10T09:30:36","modified_gmt":"2026-03-10T09:30:36","slug":"how-to-install-docker-on-ubuntu","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-install-docker-on-ubuntu","title":{"rendered":"How to install Docker on Ubuntu (Manual installation and VPS template)"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Installing Docker on Ubuntu lets you run containers to build, test, and deploy applications in a clean, consistent environment.<\/p><p>To install Docker on Ubuntu, make sure your system is running a supported version like Ubuntu <strong>22.04<\/strong> LTS or <strong>24.04<\/strong> LTS. Then, follow the manual installation steps to set up required packages, add Docker&rsquo;s official GPG key, and install Docker Engine.<\/p><p>If you&rsquo;re a Hostinger customer, you can install Docker on your Ubuntu VPS in just a few clicks using our preconfigured template.<\/p><p>Scroll down as we walk you through both methods, share helpful Docker configuration tips after installation, and demonstrate how to troubleshoot common setup issues.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Docker-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\">Download free docker cheat sheet<\/a><\/p><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites-for-installing-docker-on-ubuntu\">Prerequisites for installing Docker on Ubuntu<\/h2><p>Before installing Docker on Ubuntu, make sure you meet the following prerequisites:<\/p><ul class=\"wp-block-list\">\n<li>Familiarity with <a href=\"\/ca\/tutorials\/what-is-docker\">Docker<\/a> basics, which will help you understand what you&rsquo;re setting up and why each step matters.<\/li>\n\n\n\n<li>Basic knowledge of <a href=\"\/ca\/tutorials\/linux-commands\">Linux commands<\/a>, especially if you&rsquo;re following the manual installation approach, as you&rsquo;ll be running several commands in the terminal.<\/li>\n\n\n\n<li>A supported Ubuntu version, like Ubuntu <strong>22.04<\/strong> LTS or Ubuntu <strong>24.04<\/strong> LTS. Always check <a href=\"https:\/\/docs.docker.com\/engine\/install\/ubuntu\" target=\"_blank\" rel=\"noopener\">Docker&rsquo;s official documentation<\/a> for the latest compatibility details.<\/li>\n\n\n\n<li>A system with at least <strong>512 MB<\/strong> of RAM. For smoother performance and real-world usage, we recommend installing Docker on a system with at least <strong>2 GB<\/strong> of RAM.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-install-docker-manually\">How to install Docker manually<\/h2><p>If you prefer a hands-on approach, this section guides you through manually installing Docker on an Ubuntu <strong>24.04<\/strong> distribution. The same steps apply to other supported Ubuntu versions, such as <strong>22.04<\/strong>.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-install-all-necessary-packages\">1. Install all necessary packages<\/h3><p>To start installing Docker, verify that your system is up to date and has all the required packages installed.<\/p><ol class=\"wp-block-list\">\n<li>Open your terminal and connect to your VPS using <a href=\"\/ca\/tutorials\/ssh-tutorial-how-does-ssh-work\">SSH<\/a>. Replace <strong>username<\/strong> and <strong>your_server_ip<\/strong> with your credentials:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh username@your_server_ip<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Update your package list to ensure your server uses the newest versions of packages and their dependencies:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update &amp;&amp; sudo apt upgrade -y<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Install the necessary packages to allow <strong>apt<\/strong> to use repositories over HTTPS:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install apt-transport-https ca-certificates curl software-properties-common -y<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d360fe\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"569\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-install-dependencies-1024x569.png\" alt=\"A terminal output shows the process of installing necessary packages and dependencies\" class=\"wp-image-131657\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-2-add-docker-s-official-gpg-key\">2. Add Docker&rsquo;s official GPG key<\/h3><p>To ensure the authenticity and security of the Docker packages, you need to add Docker&rsquo;s official GPG key and set up the Docker repository.<\/p><ol class=\"wp-block-list\">\n<li>Run the following <a href=\"\/ca\/tutorials\/curl-command-with-examples-linux\">cURL command<\/a> to add Docker&rsquo;s GPG key:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<\/pre><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d37356\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"292\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-curl-docker-1024x292.png\" alt=\"A terminal output shows the process of downloading Docker's GPG key using curl\" class=\"wp-image-131658\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"2\" class=\"wp-block-list\">\n<li>Add the official Docker repository to your APT sources:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo \"deb [arch=amd64 signed-by=\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable\" | sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Update your package list to include packages from the new repository:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update<\/pre><h3 class=\"wp-block-heading\" id=\"h-3-install-docker-engine\">3. Install Docker Engine<\/h3><p>With the necessary repositories set up, you can now proceed to install Docker Engine.<\/p><ol class=\"wp-block-list\">\n<li>Make sure you install Docker from its official repository instead of the default Ubuntu repository:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">apt-cache policy docker-ce<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>You&rsquo;ll see the following output, indicating that Docker will be installed from the correct repository:<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d38662\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"647\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-docker-ce-1024x647.png\" alt=\"A terminal output shows that the latest Docker version will be installed from its official repository\" class=\"wp-image-131660\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Execute this command to install Docker Engine, Docker Community Edition, and <strong>containerd<\/strong> runtime, which are all necessary for running Docker containers:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt install docker-ce docker-ce-cli containerd.io -y<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Ensure Docker starts automatically when your system boots:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl enable docker<\/pre><h3 class=\"wp-block-heading\" id=\"h-4-verify-docker-installation\">4. Verify Docker installation<\/h3><p>After installing Docker, verify that the installation was successful and Docker is running correctly.<\/p><ol class=\"wp-block-list\">\n<li>Confirm the Docker version installed on your system:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker --version<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Here&rsquo;s the expected output:<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d39a26\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"120\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-docker-version-1024x120.png\" alt=\"A terminal output shows the installed Docker version\" class=\"wp-image-131661\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"3\" class=\"wp-block-list\">\n<li>Use the following command to check Docker&rsquo;s service status:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status docker<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>You should see an output indicating that Docker is active and running:<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d3aecb\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"553\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-systemctl-docker-active-running-highlighted-1024x553.png\" alt=\"A terminal output shows that the Docker service is currently active and running\" class=\"wp-image-131662\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"5\" class=\"wp-block-list\">\n<li>Press <strong>Q<\/strong> on your keyboard to exit this status screen.<\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-5-run-docker-without-sudo-optional\">5. Run Docker without sudo (optional)<\/h3><p>By default, Docker only lets you run its commands as the root user or with <strong>sudo<\/strong> privileges, which can be inconvenient and potentially less secure. If you attempt to run Docker commands as a non-root user, you&rsquo;ll encounter this error:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d3c26c\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"90\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-docker-permission-denied-1024x90.png\" alt=\"A terminal output shows that non-root user got a permission denied error when running a Docker command\" class=\"wp-image-131663\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>However, running Docker without <strong>sudo<\/strong> is preferable because it&rsquo;s faster and improves workflow efficiency. That&rsquo;s why we suggest creating a dedicated user to run Docker without elevated privileges.<\/p><ol class=\"wp-block-list\">\n<li>Add a new user if you don&rsquo;t have one. Here, we name it <strong>new_user<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo adduser new_user<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>You&rsquo;ll be prompted to set up a new password for this user.<\/li>\n\n\n\n<li>Run the following command to create the <strong>docker<\/strong> group:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo groupadd docker<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Add <strong>new_user<\/strong> to the <strong>docker<\/strong> group:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo usermod -aG docker new_user<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Switch to the recently created user:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">su - new_user<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Verify that this user is part of the <strong>docker<\/strong> group:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">groups<\/pre><ol start=\"7\" class=\"wp-block-list\">\n<li>Here&rsquo;s the output:<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d3da21\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"818\" height=\"130\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-user-groups.png\" alt=\"A terminal output shows the existing user groups\" class=\"wp-image-131664\"  sizes=\"auto, (max-width: 818px) 100vw, 818px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><ol start=\"8\" class=\"wp-block-list\">\n<li>Run a simple Docker command to verify that you can run commands without <strong>sudo<\/strong>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run hello-world<\/pre><ol start=\"9\" class=\"wp-block-list\">\n<li>You should see an output showing that Docker is running correctly as a non-root user:<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d3efe8\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"628\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/terminal-docker-run-1024x628.png\" alt=\"A terminal output shows that a non-root user can run a simple Docker command\" class=\"wp-image-131665\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Congratulations! You&rsquo;ve successfully set up Docker manually on an Ubuntu VPS using commands.<\/p><div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id=\"h-how-to-install-docker-on-ubuntu-using-hostinger-s-vps-template\">How to install Docker on Ubuntu using Hostinger&rsquo;s VPS template<\/h2>\n\n\n\n<p>Using Hostinger&rsquo;s preconfigured template is the easiest way to install Docker on your Ubuntu VPS. If you choose the <a href=\"\/ca\/vps\/docker-hosting\">Docker VPS hosting plan<\/a>, the template will be automatically selected, so you can start deploying containerized apps right away.<\/p>\n\n\n\n<p>If you&rsquo;re a regular VPS hosting customer, don&rsquo;t worry. You can still install Docker with just a few clicks by selecting the template yourself. Here are the steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to hPanel and navigate to <strong>VPS &rarr; Manage<\/strong> next to your server.<\/li>\n\n\n\n<li>From the <strong>VPS<\/strong> dashboard, go to <strong>OS &amp; Panel &rarr; Operating System<\/strong> in the left sidebar.<\/li>\n\n\n\n<li>Find the <strong>Change OS <\/strong>section, type <strong>Docker <\/strong>in the search bar, then select the <strong>Docker <\/strong>template.<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69e29d0d404a8\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"2086\" height=\"690\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-change-os-docker-highlighted.png\" alt=\"The Docker template in hPanel's VPS\" class=\"wp-image-131710\"  sizes=\"auto, (max-width: 2086px) 100vw, 2086px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div>\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Follow the on-screen instructions and wait for the installation process to finish, which typically takes about <strong>10 minutes<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p>That&rsquo;s it! You have installed Docker on your VPS and are ready to deploy apps.<\/p>\n\n\n<?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ca\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner-1024x300.png\" alt=\"\" class=\"wp-image-77934\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div><\/div><h2 class=\"wp-block-heading\" id=\"h-what-are-some-docker-configuration-tips\">What are some Docker configuration tips?<\/h2><p>After installing Docker on Ubuntu, take some time to learn the core commands and useful configurations below to get the most out of it.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-learn-basic-docker-commands\"><strong>1. Learn basic Docker commands<\/strong><\/h3><p>Start by mastering essential <a href=\"\/ca\/tutorials\/docker-cheat-sheet\">Docker commands<\/a> to interact with images and containers. This way, you can search and pull prebuilt images like <strong>nginx<\/strong>, <strong>node<\/strong>, or <strong>mysql<\/strong> to quickly launch services without installing anything manually.<\/p><ul class=\"wp-block-list\">\n<li><strong>List images<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker images<\/pre><ul class=\"wp-block-list\">\n<li><strong>Search for images on Docker Hub<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker search nginx<\/pre><ul class=\"wp-block-list\">\n<li><strong>Download an image<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker pull nginx<\/pre><h3 class=\"wp-block-heading\" id=\"h-2-run-and-manage-containers\"><strong>2. Run and manage containers<\/strong><\/h3><p>Once you have an image, you can launch and control containers using the following commands. The example below <a href=\"\/ca\/tutorials\/docker-run-nginx\">runs a containerized NGINX server<\/a> on port <strong>8080<\/strong>. This is perfect for testing static websites locally or building reverse proxies for your apps.<\/p><ul class=\"wp-block-list\">\n<li><strong>Run a container<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -d --name webserver -p 8080:80 nginx<\/pre><ul class=\"wp-block-list\">\n<li><a href=\"\/ca\/tutorials\/docker-start-a-container\">Start your first container<\/a>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker start webserver<\/pre><ul class=\"wp-block-list\">\n<li><strong>Stop a running container<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker stop webserver<\/pre><ul class=\"wp-block-list\">\n<li><strong>List running containers<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker ps<\/pre><h3 class=\"wp-block-heading\" id=\"h-3-build-and-share-your-own-images\"><strong>3. Build and share your own images<\/strong><\/h3><p>You can create your own images using a Dockerfile and share them with others. One use case is to package your Node.js, Python, or Go app into a reusable image and deploy it across different environments or share it with your team.<\/p><ul class=\"wp-block-list\">\n<li><strong>Build an image from the current directory<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker build -t my-app .<\/pre><ul class=\"wp-block-list\">\n<li><strong>Tag the image<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker tag my-app yourusername\/my-app:latest<\/pre><ul class=\"wp-block-list\">\n<li><strong>Push the image to Docker Hub<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker push yourusername\/my-app:latest<\/pre><h3 class=\"wp-block-heading\" id=\"h-4-clean-up-unused-components\"><strong>4. Clean up unused components<\/strong><\/h3><p>Clean up Docker resources you no longer need to avoid unnecessary disk usage. This helps free up space and reduce clutter from test runs or temporary builds.<\/p><ul class=\"wp-block-list\">\n<li><a href=\"http:\/\/tutorials\/how-to-remove-docker-images\">Remove unused Docker images<\/a>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker image prune<\/pre><ul class=\"wp-block-list\">\n<li><strong>Delete stopped containers<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker container prune<\/pre><ul class=\"wp-block-list\">\n<li><strong>Remove unused volumes and networks<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker volume prune\ndocker network prune<\/pre><h3 class=\"wp-block-heading\" id=\"h-5-use-docker-compose-for-multi-container-apps\"><strong>5. Use Docker Compose for multi-container apps<\/strong><\/h3><p>Docker Compose lets you define and manage multi-service environments using a single <strong>docker-compose.yml<\/strong> file.<\/p><ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: Quickly <a href=\"\/ca\/tutorials\/run-docker-wordpress\">run WordPress as a Docker container<\/a> for local testing:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">version: '3.8'\n\n\nservices:\n  db:\n    image: mysql:5.7\n    restart: always\n    environment:\n      MYSQL_DATABASE: wordpress\n      MYSQL_USER: wp_user\n      MYSQL_PASSWORD: wp_pass\n      MYSQL_ROOT_PASSWORD: example\n    volumes:\n      - db_data:\/var\/lib\/mysql\n\n\n  web:\n    image: wordpress\n    restart: always\n    ports:\n      - \"8080:80\"\n    environment:\n      WORDPRESS_DB_HOST: db:3306\n      WORDPRESS_DB_NAME: wordpress\n      WORDPRESS_DB_USER: wp_user\n      WORDPRESS_DB_PASSWORD: wp_pass\n    depends_on:\n      - db\n\n\nvolumes:\n  db_data:<\/pre><ul class=\"wp-block-list\">\n<li><strong>Start all services<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker-compose up -d<\/pre><h3 class=\"wp-block-heading\" id=\"h-6-create-isolated-development-environments\"><strong>6. Create isolated development environments<\/strong><\/h3><p>Use Docker to avoid polluting your system with multiple language versions or dependencies. This is useful for testing packages, writing scripts, or building apps in an isolated container &ndash; all without changing your host setup.<\/p><ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: <a href=\"\/ca\/tutorials\/how-to-use-node-js-with-docker\">Use Docker to run a Node.js environment<\/a> without installing Node locally:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -it --rm node:18 bash<\/pre><h3 class=\"wp-block-heading\" id=\"h-7-automate-builds-and-tests-in-ci-cd\"><strong>7. Automate builds and tests in CI\/CD<\/strong><\/h3><p>Docker is widely supported in CI tools like GitHub Actions, GitLab CI\/CD, and Jenkins. You can containerize your app and run it consistently in development, staging, and production.<\/p><ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: Use a Docker image in your GitHub Actions pipeline to automate testing:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">jobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions\/checkout@v3\n      - run: docker build -t my-app .\n      - run: docker run my-app npm test<\/pre><h3 class=\"wp-block-heading\" id=\"h-8-host-web-servers-or-apis-locally\"><strong>8. Host web servers or APIs locally<\/strong><\/h3><p>You can run full web servers or APIs inside containers to test your apps without deploying them externally. This is ideal for front-end developers who need to serve static assets or test local domains without setting up a full development server.<\/p><ul class=\"wp-block-list\">\n<li><strong>Example<\/strong>: Run a basic Apache server locally:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run -d -p 8080:80 httpd<\/pre><h2 class=\"wp-block-heading\" id=\"h-troubleshooting-common-docker-installation-issues\">Troubleshooting common Docker installation issues<\/h2><p>Installing Docker on Ubuntu is usually smooth, but some errors can occur depending on your setup, system configuration, or user permissions. Below are common issues, along with actionable solutions and commands to help you debug quickly.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-docker-daemon-not-running\"><strong>1.<\/strong> <strong>Docker daemon not running<\/strong><\/h3><p>An error message like &ldquo;Cannot connect to the Docker daemon&rdquo; usually indicates that the Docker service isn&rsquo;t active.<\/p><ul class=\"wp-block-list\">\n<li><strong>Start the service<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl start docker<\/pre><ul class=\"wp-block-list\">\n<li><strong>Enable it to start at boot<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl enable docker<\/pre><ul class=\"wp-block-list\">\n<li><strong>Check the daemon status<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status docker<\/pre><p>If Docker still doesn&rsquo;t start, check the logs using <a href=\"\/ca\/tutorials\/journalctl-command\">journalctl<\/a>:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">journalctl -u docker.service<\/pre><p>Look for errors such as missing configuration files, port conflicts, or storage driver issues.<\/p><h3 class=\"wp-block-heading\" id=\"h-2-can-t-connect-to-the-docker-socket\"><strong>2. Can&rsquo;t connect to the Docker socket<\/strong><\/h3><p>If you see &ldquo;Got permission denied while trying to connect to the Docker daemon socket,&rdquo; it&rsquo;s likely a user permission issue.<\/p><ul class=\"wp-block-list\">\n<li><strong>Check if your user is in the docker group<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">groups<\/pre><ul class=\"wp-block-list\">\n<li><strong>Add your user to the group<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo usermod -aG docker user<\/pre><p>Then, log out and back in as that user.<\/p><ul class=\"wp-block-list\">\n<li><strong>Restart the Docker service<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl restart docker<\/pre><p>If the problem persists, check out our tutorial on <a href=\"\/ca\/tutorials\/how-to-fix-docker-permission-denied-error\">how to fix Docker permission issues<\/a>.<\/p><h3 class=\"wp-block-heading\" id=\"h-3-repository-and-installation-issues\"><strong>3. Repository and installation issues<\/strong><\/h3><p>If you encounter issues with adding the Docker APT repository or installing packages, it might be due to:<\/p><ul class=\"wp-block-list\">\n<li>Incorrect repository URL.<\/li>\n\n\n\n<li>Missing dependencies.<\/li>\n\n\n\n<li>Unsupported Ubuntu version.<\/li>\n<\/ul><p>Make sure you&rsquo;ve added the correct repository:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg --dearmor -o \/etc\/apt\/keyrings\/docker.gpg<\/pre><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo \n  \"deb [arch=$(dpkg --print-architecture) signed-by=\/etc\/apt\/keyrings\/docker.gpg] \n  https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable\" | \n  sudo tee \/etc\/apt\/sources.list.d\/docker.list &gt; \/dev\/null<\/pre><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo apt update<\/pre><p>If <strong>apt update<\/strong> fails, check the output for malformed entries or GPG key errors.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-running-containers-are-unresponsive\"><strong>4. Running containers are unresponsive<\/strong><\/h3><p>If your container starts but doesn&rsquo;t behave as expected, try the following:<\/p><ul class=\"wp-block-list\">\n<li><strong>View container logs<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker logs container_name<\/pre><ul class=\"wp-block-list\">\n<li><strong>Check container health if defined<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker inspect --format='{{json .State.Health}}' container_name<\/pre><ul class=\"wp-block-list\">\n<li><strong>Restart the container<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker restart container_name<\/pre><p>Alternatively, Hostinger VPS users can ask the <strong>Kodee AI Assistant<\/strong> to check their container logs. Simply type, &ldquo;Can you check the logs of the [container_name] container?&rdquo; like in this example:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"69e29d0d423b2\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-large wp-lightbox-container\"><img decoding=\"async\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-on-async--load=\"callbacks.setButtonStyles\" data-wp-on-async-window--resize=\"callbacks.setButtonStyles\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2019\/03\/hpanel-vps-kodee-docker-1024x441.png\" alt=\"Kodee responds to a question about Docker logs of a container\"><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on-async--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><h3 class=\"wp-block-heading\" id=\"h-5-firewall-and-network-issues\"><strong>5. Firewall and network issues<\/strong><\/h3><p>Docker uses several ports internally. If you have a firewall enabled, such as <a href=\"\/ca\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\">Uncomplicated Firewall (UFW)<\/a>, these ports might be blocked.<\/p><ul class=\"wp-block-list\">\n<li><strong>Allow Docker-related traffic with UFW<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ufw allow 2375\/tcp\nsudo ufw allow 2376\/tcp\nsudo ufw allow 2377\/tcp\nsudo ufw allow 7946\/tcp\nsudo ufw allow 7946\/udp\nsudo ufw allow 4789\/udp<\/pre><ul class=\"wp-block-list\">\n<li><strong>Check if Docker can resolve DNS<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run busybox nslookup google.com<\/pre><p>If this fails, your container network might be misconfigured.<\/p><ul class=\"wp-block-list\">\n<li><strong>Recreate the default bridge network<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker network rm bridge\ndocker network create --driver bridge bridge<\/pre><p><div class=\"protip\">\n                    <h4 class=\"title\">Managing firewall with Kodee<\/h4>\n                    <p>You can also ask <strong>Kodee<\/strong> to set new firewall rules on your VPS. Simply type, \"Set new firewall rules that open port 2375, 2376, 2377, 7946 TCP and 7946, 4789 UDP to any IP address.\"<\/p>\n                <\/div>\n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-6-slow-docker-performance\"><strong>6. Slow Docker performance<\/strong><\/h3><p>If Docker feels sluggish &ndash; for example, if image pulls are slow or containers are lagging &ndash; try these steps to troubleshoot the issue.<\/p><ul class=\"wp-block-list\">\n<li><strong>Check disk space<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">df -h<\/pre><ul class=\"wp-block-list\">\n<li><strong>Check Docker system usage<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker system df<\/pre><ul class=\"wp-block-list\">\n<li><strong>List heavy containers or volumes<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker ps -s\ndocker volume ls<\/pre><p>If none of the above steps work, try cleaning up unused containers, networks, images, and build cache to improve performance:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker system prune -a<\/pre><h3 class=\"wp-block-heading\" id=\"h-7-security-or-apparmor-errors\"><strong>7. Security or AppArmor errors<\/strong><\/h3><p>On some Ubuntu setups, Docker may fail to start containers due to conflicts with security modules, such as AppArmor.<\/p><ul class=\"wp-block-list\">\n<li><strong>Check for AppArmor denials<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">dmesg | grep apparmor<\/pre><ul class=\"wp-block-list\">\n<li><strong>Temporarily disable AppArmor for a container<\/strong>:<\/li>\n<\/ul><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run --security-opt apparmor=unconfined your_image<\/pre><p>Please note that disabling AppArmor is not recommended in a production environment. If you choose to do so, make sure you&rsquo;re not unintentionally overriding important kernel security features.<\/p><p>If these errors persist, consider checking your system logs in <strong>\/var\/log\/syslog<\/strong>.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-s-next\">What&rsquo;s next?<\/h2><p>Installing Docker on Ubuntu gives you the flexibility to deploy, test, and ship software with fewer headaches, whether you&rsquo;re running apps locally or managing production workloads.<\/p><p>But installation is just the beginning. To truly benefit from Docker, explore how containers fit into your long-term workflow:<\/p><ul class=\"wp-block-list\">\n<li>Find real-world <a href=\"\/ca\/tutorials\/docker-use-cases\">Docker use cases<\/a>, such as running web apps, databases, or CI pipelines, and get ideas for applying them in your own projects.<\/li>\n\n\n\n<li>Use <a href=\"\/ca\/tutorials\/docker-exec-command\">docker exec<\/a> to interact with running containers by executing commands directly for debugging, configuration, or live updates &ndash; all without restarting anything.<\/li>\n\n\n\n<li>Handle <a href=\"\/ca\/tutorials\/docker-build-secrets\">Docker secrets<\/a> securely by avoiding hardcoded passwords or tokens and passing sensitive data safely during build or runtime.<\/li>\n\n\n\n<li>Set up <a href=\"\/ca\/tutorials\/how-to-create-docker-swarm\">Docker Swarm<\/a> for orchestration to scale your apps beyond single containers and manage a multi-node cluster efficiently with built-in load balancing.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Installing Docker on Ubuntu lets you run containers to build, test, and deploy applications in a clean, consistent environment. To install Docker on Ubuntu, make sure your system is running a supported version like Ubuntu 22.04 LTS or 24.04 LTS. Then, follow the manual installation steps to set up required packages, add Docker&rsquo;s official GPG [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-install-docker-on-ubuntu\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":139825,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to install Docker on Ubuntu (Manual and VPS template)","rank_math_description":"Learn how to install Docker on Ubuntu using the manual method or a VPS template. Step-by-step guide for beginners and developers.","rank_math_focus_keyword":"install docker ubuntu","footnotes":""},"categories":[22701,22699],"tags":[],"class_list":["post-16179","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-pre-installed-applications","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/instalar-docker-ubuntu","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/installer-docker-sur-ubuntu","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-instalar-y-usar-docker-en-ubuntu","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-install-docker-ubuntu","default":0},{"locale":"ja-JP","link":"https:\/\/www.hostinger.com\/jp\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"ar-AE","link":"https:\/\/www.hostinger.com\/ae\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-instalar-y-usar-docker-en-ubuntu","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-instalar-y-usar-docker-en-ubuntu","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-instalar-y-usar-docker-en-ubuntu","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/instalar-docker-ubuntu","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-docker-on-ubuntu","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-docker-on-ubuntu","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/16179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=16179"}],"version-history":[{"count":62,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/16179\/revisions"}],"predecessor-version":[{"id":138959,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/16179\/revisions\/138959"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media\/139825"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=16179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=16179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=16179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}