{"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":"2025-04-17T14:55:53","modified_gmt":"2025-04-17T14:55:53","slug":"how-to-install-docker-on-ubuntu","status":"publish","type":"post","link":"\/in\/tutorials\/how-to-install-docker-on-ubuntu","title":{"rendered":"How to Install Docker on Ubuntu Using VPS Template and Manually"},"content":{"rendered":"<p>Docker is a powerful platform to automate application deployments using lightweight, portable containers. Setting up Docker on a Linux server can significantly enhance your development workflow.<\/p><p>In this guide, you&rsquo;ll learn how to install Docker on Ubuntu using Hostinger&rsquo;s VPS template and manually. By the end of this article, you&rsquo;ll have a fully functional Docker setup ready for your projects.<\/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\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites-for-docker-installation-on-ubuntu\">Prerequisites for Docker Installation on Ubuntu<\/h2><p>Before following our Docker installation guide, make sure your Ubuntu system meets the following prerequisites:<\/p><ul class=\"wp-block-list\">\n<li><strong>Supported Ubuntu version<\/strong>. Use a long-term support (LTS) version of Ubuntu, such as <strong>Ubuntu 20.04, 22.04, <\/strong>or<strong> 24.04<\/strong>.<\/li>\n\n\n\n<li><strong>Server requirements<\/strong>. Verify that your VPS meets the minimum requirements for Docker. Your system should have a <strong>64-bit<\/strong> architecture and at least <strong>2 GB<\/strong> of RAM.<\/li>\n\n\n\n<li><strong>Basic Linux knowledge<\/strong>. Familiarity with <a href=\"\/in\/tutorials\/linux-commands\">basic Linux commands<\/a> is beneficial for installing and managing Docker applications.<\/li>\n<\/ul><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p>Need a refresher on <a href=\"\/in\/tutorials\/what-is-docker\">what Docker is<\/a>? Check out our article to understand how Docker works and what its components are.<\/p>\n                <\/div>\n\n\n\n<\/p><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><p>Using Hostinger&rsquo;s preconfigured template is the easiest way to set up Docker on your Ubuntu VPS. Available for both VPS and <a href=\"\/in\/vps\/docker-hosting\">Docker hosting<\/a> plans, this method saves time and ensures Docker is installed correctly with all necessary components.<\/p><p>Follow these steps to install Docker with Hostinger&rsquo;s VPS template:<\/p><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<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69debb4a017c3\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"512\" height=\"834\" 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\/os-panel-menu-sidebar-hpanel.png\" alt=\"The OS &amp; Panel menu on hPanel's sidebar\" class=\"wp-image-125855\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/os-panel-menu-sidebar-hpanel.png 512w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/os-panel-menu-sidebar-hpanel-184x300.png 184w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/os-panel-menu-sidebar-hpanel-92x150.png 92w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><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>On the <strong>Operating System<\/strong> page, select <strong>Application &rarr; Docker<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69debb4a0bc1a\"}' data-wp-interactive=\"core\/image\" class=\"aligncenter size-full wp-lightbox-container\"><img decoding=\"async\" width=\"1460\" height=\"373\" 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\/docker-vps-template-on-hpanel-operating-system-configuration-page.png\" alt=\"The Docker VPS template on hPanel's operating system configuration page\" class=\"wp-image-125857\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/docker-vps-template-on-hpanel-operating-system-configuration-page.png 1460w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/docker-vps-template-on-hpanel-operating-system-configuration-page-300x77.png 300w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/docker-vps-template-on-hpanel-operating-system-configuration-page-1024x262.png 1024w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/docker-vps-template-on-hpanel-operating-system-configuration-page-150x38.png 150w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2019\/03\/docker-vps-template-on-hpanel-operating-system-configuration-page-768x196.png 768w\" sizes=\"(max-width: 1460px) 100vw, 1460px\" \/><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=\"4\" class=\"wp-block-list\">\n<li>Click the <strong>Change OS<\/strong> button and wait for the installation process to finish, which typically takes about 10 minutes.<\/li>\n<\/ol><p>That&rsquo;s it! You have installed Docker on your VPS and are ready to deploy applications.<\/p><?xml encoding=\"utf-8\" ?><figure class=\"wp-block-image size-large\"><a href=\"\/in\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img 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\" srcset=\"https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner.png 1024w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner-300x88.png 300w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner-150x44.png 150w, https:\/\/www.hostinger.com\/in\/tutorials\/wp-content\/uploads\/sites\/52\/2023\/02\/VPS-hosting-banner-768x225.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-how-to-manually-install-docker\">How to Manually Install Docker<\/h2><p>For those who prefer a hands-on approach, this section will guide you through manually installing Docker on an <strong>Ubuntu 24.04<\/strong> distribution.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-install-necessary-packages\">1. Install Necessary Packages<\/h3><p>To begin installing Docker, verify that your system is up to date and has all the required packages installed. Follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>Open your terminal and connect to your VPS using <a href=\"\/in\/tutorials\/ssh-tutorial-how-does-ssh-work\">SSH<\/a>. Replace <strong>username<\/strong> and <strong>your_server_ip<\/strong> with your actual credentials:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">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=\"wp-block-preformatted\">sudo apt update<br><br>sudo apt upgrade<\/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=\"wp-block-preformatted\">sudo apt install apt-transport-https ca-certificates curl software-properties-common<\/pre><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. Here&rsquo;s the guide:<\/p><ol class=\"wp-block-list\">\n<li>Run the following <a href=\"\/in\/tutorials\/curl-command-with-examples-linux\">curl command<\/a> to add Docker&rsquo;s GPG key:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Add the official Docker repository to your APT sources:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">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=\"wp-block-preformatted\">sudo apt update<\/pre><h3 class=\"wp-block-heading\" id=\"h-3-install-docker\">3. Install Docker<\/h3><p>With the necessary repositories set up, you can now proceed to install Docker. Here are the steps to do so:<\/p><ol class=\"wp-block-list\">\n<li>Make sure you&rsquo;re about to install Docker from its official repository instead of the default Ubuntu repository:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">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><pre class=\"wp-block-preformatted\">docker-ce:<br><br>&nbsp;Installed: (none)<br><br>&nbsp;Candidate: 5:26.1.3-1~ubuntu.24.04~noble<br><br>&nbsp;Version table:<br><br>&nbsp;5:26.1.3-1~ubuntu.24.04~noble 500<br><br>&nbsp;500 https:\/\/download.docker.com\/linux\/ubuntu noble\/stable amd64 Packages<br><br>&nbsp;5:26.1.2-1~ubuntu.24.04~noble 500<br><br>&nbsp;500 https:\/\/download.docker.com\/linux\/ubuntu noble\/stable amd64 Packages<br><br>&nbsp;5:26.1.1-1~ubuntu.24.04~noble 500<br><br>&nbsp;500 https:\/\/download.docker.com\/linux\/ubuntu noble\/stable amd64 Packages<br><br>&hellip;<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Execute this command to install Docker Engine, Docker Community Edition, and <strong>containerd<\/strong> runtime, all necessary for running Docker containers:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo apt install docker-ce docker-ce-cli containerd.io<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Ensure Docker starts automatically when your system boots:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">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, it&rsquo;s important to verify that the installation was successful and that Docker is running correctly. Here are the instructions:<\/p><ol class=\"wp-block-list\">\n<li>Confirm the Docker version installed on your system:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">docker --version<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Here&rsquo;s the expected output:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">Docker version 26.1.3, build b72abbb<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Use the following command to check the Docker service&rsquo;s status:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">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><pre class=\"wp-block-preformatted\">&#9679; docker.service - Docker Application Container Engine<br><br>&nbsp;Loaded: loaded (\/usr\/lib\/systemd\/system\/docker.service; enabled; preset: enabled)<br><br>&nbsp;Active: active (running) since Wed 2024-05-22 06:12:32 UTC; 39s ago<br><br>TriggeredBy: &#9679; docker.socket<br><br>&nbsp;Docs: https:\/\/docs.docker.com<br><br>&nbsp;Main PID: 3717 (dockerd)<br><br>&nbsp;Tasks: 9<br><br>&nbsp;Memory: 29.4M (peak: 29.8M)<br><br>&nbsp;CPU: 334ms<br><br>&nbsp;CGroup: \/system.slice\/docker.service<br><br>&nbsp;&#9492;&#9472;3717 \/usr\/bin\/dockerd -H fd:\/\/ --containerd=\/run\/containerd\/containerd.sock<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>To exit from this status screen, press <strong>Ctrl + C<\/strong> on your keyboard.<\/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 allows you to run its commands as a root user 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 might see an error like this:<\/p><pre class=\"wp-block-preformatted\">docker: Cannot connect to the Docker daemon at unix:\/\/\/var\/run\/docker.sock. Is the docker daemon running?.<\/pre><p>However, running Docker without <strong>sudo<\/strong> is more advisable because it&rsquo;s quicker and simpler. Follow this guide:<\/p><ol class=\"wp-block-list\">\n<li>Run the following command to create the <strong>docker<\/strong> group:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo groupadd docker<\/pre><ol start=\"2\" 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=\"wp-block-preformatted\">sudo usermod -aG docker new_user<\/pre><ol start=\"3\" 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>Add <strong>new_user<\/strong> to the <strong>docker<\/strong> group:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">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=\"wp-block-preformatted\">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=\"wp-block-preformatted\">groups<\/pre><ol start=\"7\" class=\"wp-block-list\">\n<li>Here&rsquo;s the output:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">new_user users docker<\/pre><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=\"wp-block-preformatted\">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><pre class=\"wp-block-preformatted\">Unable to find image 'hello-world:latest' locally<br><br>latest: Pulling from library\/hello-world<br><br>c1ec31eb5944: Pull complete&nbsp;<br><br>Digest: sha256:266b191e926f65542fa8daaec01a192c4d292bff79426f47300a046e1bc576fd<br><br>Status: Downloaded newer image for hello-world:latest<br><br>Hello from Docker!<br><br>This message shows that your installation appears to be working correctly.<\/pre><p>Congratulations! You&rsquo;ve successfully set up Docker manually on an Ubuntu VPS using commands.<\/p><h2 class=\"wp-block-heading\" id=\"h-troubleshooting-common-docker-installation-issues\">Troubleshooting Common Docker Installation Issues<\/h2><p>Installing Docker can sometimes come with challenges. Here are some common issues and actionable tips to resolve them.<\/p><p><strong>Docker Daemon Not Running<\/strong><\/p><p>If you receive an error message indicating that the Docker daemon is not running, it likely means the service is not active. To resolve this, start the Docker service using the command:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl start docker<\/pre><p>You can verify the Docker daemon&rsquo;s status by running:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl status docker<\/pre><p><strong>Cannot Connect to the Docker Daemon<\/strong><\/p><p>If you encounter the &ldquo;Cannot connect to the Docker daemon at unix:\/\/\/var\/run\/docker.sock&rdquo; error, it usually means the Docker service is not running or there are permission issues.<\/p><p>First, make sure the Docker service is running with:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl start docker<\/pre><p>Then, verify that your user is part of the Docker group by running the following:<\/p><pre class=\"wp-block-preformatted\">groups<\/pre><p>To <a href=\"\/in\/tutorials\/how-to-fix-docker-permission-denied-error\">solve permission denied issues<\/a>, follow our detailed tutorial.<\/p><p><strong>Installation Issues from Repositories<\/strong><\/p><p>Problems when adding the Docker APT repository or during package installation can arise from incorrect repository setup. Make sure you have added the official repository and updated your package list by running:<\/p><pre class=\"wp-block-preformatted\">sudo add-apt-repository \"deb [arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu $(lsb_release -cs) stable\"<br><br>sudo apt update<\/pre><p><strong>Running Containers Not Responding<\/strong><\/p><p>If running containers are not responding or behaving unexpectedly, check the container logs to diagnose the issue. Use the command:<\/p><pre class=\"wp-block-preformatted\">docker logs container_id<\/pre><p>Alternatively, Hostinger VPS users can use the <strong>Kodee<\/strong> AI Assistant to check their container logs. Simply ask, &ldquo;Can you check the logs of the [container_name] container?&rdquo; like the following example:<\/p><div class=\"wp-block-image\">\n<figure data-wp-context='{\"imageId\":\"69debb4a0e1c0\"}' 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><p>If necessary, restart the container by executing:<\/p><pre class=\"wp-block-preformatted\">docker restart container_id<\/pre><p><strong>Firewall and Network Configuration<\/strong><\/p><p>Sometimes, Docker might face issues due to firewall settings or network configurations blocking necessary ports. Ensure that your firewall allows traffic on Docker&rsquo;s default ports. You can check your firewall rules and add necessary exceptions if required.<\/p><p>For example, if you&rsquo;re using <a href=\"\/in\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\">Uncomplicated Firewall (UFW)<\/a>, you can allow Docker traffic with:<\/p><pre class=\"wp-block-preformatted\">sudo ufw allow 2375\/tcp<br><br>sudo ufw allow 2376\/tcp<br><br>sudo ufw allow 2377\/tcp<br><br>sudo ufw allow 7946\/tcp<br><br>sudo ufw allow 7946\/udp<br><br>sudo ufw allow 4789\/udp<\/pre><p>Additionally, verify your network settings to ensure Docker can communicate with external servers to download images and perform other tasks.<\/p><h2 class=\"wp-block-heading\" id=\"h-post-installation-configuration-and-tips\">Post-Installation Configuration and Tips<\/h2><p>After installing Docker, new users should become familiar with several necessary commands and tasks. This section will cover some Docker post-installation configurations and tips.<\/p><p><strong>Basic Docker Commands<\/strong><\/p><p>Getting started with Docker involves learning a few essential commands. Here are some commands that every new user should know:<\/p><ul class=\"wp-block-list\">\n<li>List Docker images:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker images<\/pre><ul class=\"wp-block-list\">\n<li>Search for images on Docker Hub:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker search image_name<\/pre><ul class=\"wp-block-list\">\n<li>Download a Docker image from Docker Hub:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker pull image_name<\/pre><p>Furthermore, check our <a href=\"\/in\/tutorials\/docker-cheat-sheet\">Docker cheat sheet<\/a> guide to learn all the most essential commands and their purposes.<\/p><p><strong>Running and Managing Docker Containers<\/strong><\/p><p>Running and managing containers is a core part of working with Docker. Here&rsquo;s a guide to perform these tasks:<\/p><ul class=\"wp-block-list\">\n<li>Run a Docker container using the specified image:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker run -d --name container_name image_name<\/pre><ul class=\"wp-block-list\">\n<li><a href=\"\/in\/tutorials\/docker-start-a-container\">Start a Docker container<\/a>:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker start container_id_or_name<\/pre><ul class=\"wp-block-list\">\n<li>Stop a running container:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker stop container_id_or_name<\/pre><ul class=\"wp-block-list\">\n<li>List all running containers:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker ps<\/pre><p><strong>Working with Docker Images<\/strong><\/p><p>Docker images are the basis for containers. Here&rsquo;s how you can work with images:<\/p><ul class=\"wp-block-list\">\n<li>Build a Docker image from a Dockerfile in the current directory:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker build -t image_name .<\/pre><ul class=\"wp-block-list\">\n<li>Tag an image with a specific name and tag:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker tag source_image_name target_image_name:tag<\/pre><ul class=\"wp-block-list\">\n<li>Log in to Docker Hub, tag your image, and push it to your repository:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker login<br><br>docker tag image_name dockerhub_username\/image_name:tag<br><br>docker push dockerhub_username\/image_name:tag<\/pre><p><strong>Deleting Unused Docker Components<\/strong><\/p><p>To keep your environment clean and efficient, you need to remove unused Docker components regularly. Here&rsquo;s how to do so:<\/p><ul class=\"wp-block-list\">\n<li><a href=\"\/in\/tutorials\/docker-remove-all-images-tutorial\">Remove all dangling Docker images<\/a>:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker image prune<\/pre><ul class=\"wp-block-list\">\n<li>Delete all stopped containers:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker container prune<\/pre><ul class=\"wp-block-list\">\n<li>Clean unused Docker volumes:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker volume prune<\/pre><ul class=\"wp-block-list\">\n<li>Erase all unused networks:<\/li>\n<\/ul><pre class=\"wp-block-preformatted\">docker network prune<\/pre><p><strong>Using Docker Compose<\/strong><\/p><p>Docker Compose is a powerful tool for managing multi-container applications. Here&rsquo;s a basic command to get it started:<\/p><pre class=\"wp-block-preformatted\">docker-compose up -d<\/pre><p>This starts services defined in the <strong>docker-compose.yml<\/strong> file in detached mode.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\"> Suggested Reading<\/h4>\n                    <p>Did you know that you can <a href=\"\/in\/tutorials\/run-docker-wordpress\">run WordPress as a Docker container<\/a>? Learn how in our article.<\/p>\n                <\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>In this Docker tutorial, you&rsquo;ve learned how to install Docker on an Ubuntu system, both using Hostinger&rsquo;s VPS template and a manual approach. You&rsquo;ve also understood the importance of verifying the installation and troubleshooting common issues.<\/p><p>Furthermore, it&rsquo;s advisable to practice essential Docker commands, manage containers and images, and clean up unused components. By following these instructions, you can effectively set up and manage Docker for deploying your applications.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-docker-on-ubuntu-faq\">How to Install Docker on Ubuntu FAQ<\/h2><p>This section answers the most common questions about installing Docker on Ubuntu.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1716828558903\"><h3 class=\"schema-faq-question\">Are There Any Specific Configurations Needed After Installing Docker on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">After installing Docker on Ubuntu, it&rsquo;s recommended to configure Docker to run without <strong>sudo<\/strong> for convenience. Additionally, make sure your firewall settings allow Docker traffic and adjust any necessary network configurations for smooth access to external resources.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1716828573872\"><h3 class=\"schema-faq-question\">Can I Install Docker on Any Version of Ubuntu?<\/h3> <p class=\"schema-faq-answer\">Currently, Docker supports installation on <strong>Ubuntu 20.04<\/strong>, <strong>22.04<\/strong>, and <strong>24.04<\/strong>. It&rsquo;s advisable to use a long-term support version for stability. Additionally, 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 information.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1716828583537\"><h3 class=\"schema-faq-question\">How Do I Verify if Docker Is Successfully Installed on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">To verify if Docker is successfully installed on Ubuntu, run <strong>docker &ndash;version<\/strong> to check the installed version and <strong>sudo systemctl status docker<\/strong> to confirm the Docker service is active and running.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1716828630980\"><h3 class=\"schema-faq-question\">Can I Run Docker Without Root Privileges on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">Yes, you can run Docker without root privileges by adding your user to the <strong>docker<\/strong> group. Run the command <strong>sudo usermod -aG docker your_username<\/strong> as root and then switch to the user with <strong>su &ndash; your_username<\/strong>.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Docker is a powerful platform to automate application deployments using lightweight, portable containers. Setting up Docker on a Linux server can significantly enhance your development workflow. In this guide, you&rsquo;ll learn how to install Docker on Ubuntu using Hostinger&rsquo;s VPS template and manually. By the end of this article, you&rsquo;ll have a fully functional Docker [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/in\/tutorials\/how-to-install-docker-on-ubuntu\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"","rank_math_description":"","rank_math_focus_keyword":"","footnotes":""},"categories":[22642,22640],"tags":[],"class_list":["post-16179","post","type-post","status-publish","format-standard","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\/in\/tutorials\/wp-json\/wp\/v2\/posts\/16179","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/users\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/comments?post=16179"}],"version-history":[{"count":43,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts\/16179\/revisions"}],"predecessor-version":[{"id":127141,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/posts\/16179\/revisions\/127141"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/media?parent=16179"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/categories?post=16179"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/in\/tutorials\/wp-json\/wp\/v2\/tags?post=16179"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}