{"id":16575,"date":"2024-11-02T09:02:42","date_gmt":"2024-11-02T09:02:42","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=16575"},"modified":"2024-11-02T09:04:28","modified_gmt":"2024-11-02T09:04:28","password":"","slug":"installing-and-using-docker-on-a-linux-server","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/","title":{"rendered":"Installing and Using Docker on a Linux Server"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Step 1: Update the Server<\/h2>\n\n\n\n<p>Before installing Docker, update the package index on your server:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update &amp;&amp; sudo apt upgrade -y # For Debian-based systems\n\nsudo yum update -y # For Red Hat\/CentOS-based systems<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install Docker<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">For Debian\/Ubuntu-based Systems<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install necessary prerequisites<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y apt-transport-https ca-certificates curl software-properties-common<\/code><\/pre>\n\n\n\n<p>2. Add Docker\u2019s official GPG key and repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<br>echo \"deb &#91;arch=$(dpkg --print-architecture) 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<\/code><\/pre>\n\n\n\n<p>3. <strong>Install Docker<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<br>sudo apt install -y docker-ce docker-ce-cli containerd.io<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">For CentOS\/RHEL-based Systems<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add Docker\u2019s official repository<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install -y yum-utils\n\nsudo yum-config-manager --add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo<\/code><\/pre>\n\n\n\n<p>2. <strong>Install Docker<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo yum install -y docker-ce docker-ce-cli containerd.io<\/code><\/pre>\n\n\n\n<p>3. <strong>Start and enable Docker<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl start docker<br>sudo systemctl enable docker<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Verify the Docker Installation<\/h2>\n\n\n\n<p>After installation, verify Docker by checking its version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker --version<\/code><\/pre>\n\n\n\n<p>You should see the Docker version output, confirming that it\u2019s installed correctly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Run Docker Commands Without <code>sudo<\/code><\/h2>\n\n\n\n<p>By default, Docker requires root privileges. To avoid using <code>sudo<\/code> with every Docker command:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Add your user to the <code>docker<\/code> group<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo usermod -aG docker $USER<\/code><\/pre>\n\n\n\n<p>2. <strong>Log out and back in<\/strong> to apply the group changes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Test Docker Installation<\/h2>\n\n\n\n<p>Run a test Docker container to ensure everything works as expected:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run hello-world<\/code><\/pre>\n\n\n\n<p>This command downloads a test image and runs it in a container. If it runs successfully, Docker is installed and working.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Docker Usage<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>List Docker Images<\/strong><\/h3>\n\n\n\n<p>To see the images on your system:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker images<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Pull an Image<\/strong><\/h3>\n\n\n\n<p>Download an image from Docker Hub, such as Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker pull ubuntu<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>Run a Container<\/strong><\/h3>\n\n\n\n<p>Run a container interactively using the Ubuntu image:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run -it ubuntu \/bin\/bash<\/code><\/pre>\n\n\n\n<p>This starts a new container, opens an interactive terminal, and uses <code>\/bin\/bash<\/code> as the default command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>List Running Containers<\/strong><\/h3>\n\n\n\n<p>To list all active containers:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps<\/code><\/pre>\n\n\n\n<p>To list all containers (active and inactive):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker ps -a<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>Stop a Container<\/strong><\/h3>\n\n\n\n<p>Stop a running container by using its <strong>Container ID<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker stop &lt;container_id><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>Remove a Container<\/strong><\/h3>\n\n\n\n<p>Remove a stopped container:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker rm &lt;container_id><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. <strong>Remove an Image<\/strong><\/h3>\n\n\n\n<p>Remove an unused image:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker rmi &lt;image_id><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring Docker to Start on Boot<\/h2>\n\n\n\n<p>To enable Docker to start automatically at boot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl enable docker<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Additional Configuration (Optional)<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Docker Compose<\/strong><\/h3>\n\n\n\n<p>Docker Compose is a tool that lets you define and manage multi-container Docker applications.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Install Docker Compose<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/2.0.0\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose<\/code><\/pre>\n\n\n\n<p>  2. <strong>Make it executable<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo chmod +x \/usr\/local\/bin\/docker-compose<\/code><\/pre>\n\n\n\n<p> 3. <strong>Verify installation<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker-compose --version<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Docker Swarm (for Orchestration)<\/strong><\/h3>\n\n\n\n<p>Docker Swarm is Docker\u2019s native clustering and orchestration tool, ideal for managing a cluster of Docker nodes.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Initialize Docker Swarm<\/strong>:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>docker swarm init<\/code><\/pre>\n\n\n\n<p>  2. J<strong>oin nodes to the swarm<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use the output from the <code>swarm init<\/code> command to add nodes to the swarm.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>This guide covered installing Docker on a Linux server, verifying the installation, and using Docker for container management. <\/p>\n\n\n\n<p>With Docker, you can simplify the deployment process, create reproducible environments, and easily scale your applications. Docker Compose and Docker Swarm offer extended functionality for multi-container setups and orchestration, respectively.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Step 1: Update the Server Before installing Docker, update the package index on your server: Step 2: Install Docker For Debian\/Ubuntu-based Systems 2. Add Docker\u2019s official GPG key and repository: 3. Install Docker: For CentOS\/RHEL-based Systems 2. Install Docker: 3. Start and enable Docker: Step 3: Verify the Docker Installation After installation, verify Docker by [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-16575","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-06","word_count":574,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Installing and Using Docker on a Linux Server -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Installing and Using Docker on a Linux Server -\" \/>\n<meta property=\"og:description\" content=\"Step 1: Update the Server Before installing Docker, update the package index on your server: Step 2: Install Docker For Debian\/Ubuntu-based Systems 2. Add Docker\u2019s official GPG key and repository: 3. Install Docker: For CentOS\/RHEL-based Systems 2. Install Docker: 3. Start and enable Docker: Step 3: Verify the Docker Installation After installation, verify Docker by [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-02T09:04:28+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-using-docker-on-a-linux-server\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-using-docker-on-a-linux-server\\\/\",\"name\":\"Installing and Using Docker on a Linux Server -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"datePublished\":\"2024-11-02T09:02:42+00:00\",\"dateModified\":\"2024-11-02T09:04:28+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-using-docker-on-a-linux-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-using-docker-on-a-linux-server\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/installing-and-using-docker-on-a-linux-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Installing and Using Docker on a Linux Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Installing and Using Docker on a Linux Server -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/","og_locale":"en_US","og_type":"article","og_title":"Installing and Using Docker on a Linux Server -","og_description":"Step 1: Update the Server Before installing Docker, update the package index on your server: Step 2: Install Docker For Debian\/Ubuntu-based Systems 2. Add Docker\u2019s official GPG key and repository: 3. Install Docker: For CentOS\/RHEL-based Systems 2. Install Docker: 3. Start and enable Docker: Step 3: Verify the Docker Installation After installation, verify Docker by [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/","article_modified_time":"2024-11-02T09:04:28+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/","name":"Installing and Using Docker on a Linux Server -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"datePublished":"2024-11-02T09:02:42+00:00","dateModified":"2024-11-02T09:04:28+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/installing-and-using-docker-on-a-linux-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"Installing and Using Docker on a Linux Server"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=16575"}],"version-history":[{"count":1,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16575\/revisions"}],"predecessor-version":[{"id":16576,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/16575\/revisions\/16576"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=16575"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=16575"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=16575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}