{"id":11019,"date":"2022-04-05T06:09:24","date_gmt":"2022-04-05T06:09:24","guid":{"rendered":"https:\/\/blog.cloudthat.com\/?p=11019"},"modified":"2024-06-25T11:03:04","modified_gmt":"2024-06-25T11:03:04","slug":"docker-fundamentals-use-cases-docker-commands","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/explore-docker-fundamentals-use-cases-and-docker-commands","title":{"rendered":"Explore Docker Fundamentals, Use Cases, And Docker Commands"},"content":{"rendered":"<p>The requirement of Docker came into existence to solve application deployment.<\/p>\n<p><em>&#8220;Hey, it works on your computer but not on mine.&#8221;<\/em><\/p>\n<p>Today we will discuss the fundamentals of Docker. With the help of Docker, deployment of software applications is made easy, thus integrating the DevOps lifecycle for faster release, scalability, and lower downtime. DevOps is a combination of two distinct fields: development and operations. The majority of businesses have taken initiatives to implement DevOps principles. Learn more about the <a href=\"https:\/\/blog.cloudthat.com\/7-in-demand-devops-skills-to-nurture-an-it-career\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=7-in-demand-devops-skills-to-nurture-an-it-care\" target=\"_blank\" rel=\"noopener\"><strong>7 In-demand DevOps skills to nurture an IT Career here. <\/strong><\/a><\/p>\n<table style=\"height: 219px;\" border=\"3\" width=\"349\">\n<tbody>\n<tr>\n<td>\n<h2><strong><span style=\"color: #000080;\">TABLE OF CONTENT<\/span><\/strong><\/h2>\n<\/td>\n<\/tr>\n<tr>\n<td><a href=\"#introduction\">1. Introduction to Docker<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"#terms\">2. Terms used in Docker<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"#usecase\">3. Docker Use Case<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"#dockercommands\">4. Top Docker Commands<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"#conclusion\">5. Conclusion<\/a><\/td>\n<\/tr>\n<tr>\n<td><a href=\"#aboutcloudthat\">6. About CloudThat <\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 id=\"introduction\"><strong>1. Introduction to Docker<\/strong><\/h2>\n<p>Docker is an open-source tool that helps us automate the deployment process of a software application in virtual machines named containers. Docker&#8217;s main benefit is that it enables users to package an application and all of its dependencies into a single unit\u00a0for software development. In addition, unlike virtual machines, containers have low overhead, allowing for more efficient use of the underlying system and resources.<\/p>\n<p>Learn more about <a href=\"https:\/\/blog.cloudthat.com\/docker-lightweight-containers-in-limelight\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=docker-lightweight-containers-in-limelight\/\" target=\"_blank\" rel=\"noopener\"><strong>Docker: Lightweight Containers in Limelight here<\/strong><\/a>.<\/p>\n<h3><strong>2. Terms used in Docker<\/strong><\/h3>\n<p>The following are the more commonly used terms in Docker:<\/p>\n<ol>\n<li><span style=\"text-decoration: underline;\"><strong>Docker Image:<\/strong><\/span><\/li>\n<\/ol>\n<p>A Docker image is a read-only blueprint that contains instructions for building a virtual environment to run the application known as\u00a0a Docker container. It gives you a simple way to package applications and pre-configured server environments that you can use privately or share publicly to deploy the application. In simple words, it is like a template used to create a deployment environment.<\/p>\n<ol start=\"2\">\n<li><span style=\"text-decoration: underline;\"><strong>Docker Container:<\/strong><\/span><\/li>\n<\/ol>\n<p>Docker Container is an instance of a Docker Image. It creates an isolated environment containing the required software and packages to deploy the application. Docker Containers enable you to package your application and all its dependencies into a container, ensuring that it runs smoothly in any environment.<\/p>\n<ol start=\"3\">\n<li><span style=\"text-decoration: underline;\"><strong>Docker Hub:<\/strong><\/span><\/li>\n<\/ol>\n<p>Docker images are stored in a registry, and it can be thought of as a directory of all available Docker images. Users can host their Docker registries and use them to pull pictures if necessary. It works as a central repository to store and track changes in our Images.<\/p>\n<ol start=\"4\">\n<li><span style=\"text-decoration: underline;\"><strong>Docker Daemon: <\/strong><\/span><\/li>\n<\/ol>\n<p>The Daemon is a process that runs a background service on the host operating system, which is used to manage the building, running, and distributing of Docker Containers. Docker Clients communicate with the daemon process to run the containers.<\/p>\n<ol start=\"5\">\n<li><span style=\"text-decoration: underline;\"><strong>Docker Client:<br \/>\n<\/strong><\/span>Docker users interact with Docker through the Docker client which has a CLI. When you issue commands like docker run, the client sends them to Daemon, which executes them. The docker command uses the Docker API. The Docker client can communicate with multiple daemons.<span style=\"text-decoration: underline;\"><strong><br \/>\n<\/strong><\/span><\/li>\n<li><strong><span style=\"text-decoration: underline;\">Docker Registry:\u00a0<\/span><\/strong><\/li>\n<\/ol>\n<p>A registry is a storage and content delivery system, holding named Docker images, available in different tagged versions.<\/p>\n<h2 id=\"usecase\"><strong>3. Docker Use Case:<\/strong><\/h2>\n<p>Consider a team working on a Java application. Various groups are involved in the Software Development lifecycle: designing, development, testing, production, deployment, etc.<\/p>\n<p>The developer will create an environment that includes a Tomcat server. The tester must test the application after it has been developed. The tester will now create a new Tomcat environment to test the application from scratch. The application will be deployed to the production server when the testing is completed. Again, Tomcat must be installed in the production environment to host the Java application. The same Tomcat environment setup is done three times. While various teams are engaged in launching the application,<\/p>\n<p>To overcome this problem, we use Docker. In Docker, if we can create an image that contains information about required packages, say Tomcat server, to run the Java application, we can share that image to testing and production environment. Then, they can run that image which creates a container where the Java application gets hosted in an isolated environment.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11020\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker1.jpg\" alt=\"Docker Fundamentals\" width=\"987\" height=\"308\" \/><\/a><\/p>\n<h2 id=\"dockercommands\"><strong>4. Top Docker Commands<\/strong><\/h2>\n<h3>Hello-World Docker Image<\/h3>\n<p>If you are ready with the Docker setup, you can directly try to run the below command to check whether the setup is working correctly.<\/p>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker2.jpg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11021\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker2.jpg.png\" alt=\"Docker Fundamentals\" width=\"863\" height=\"321\" \/><\/a><\/p>\n<h3>Display existing images:<\/h3>\n<p><strong>-&gt;<\/strong>To pull an image from Docker Hub use the below command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true\">$ docker pull &lt;image-name&gt;<\/pre>\n<p><strong>-&gt;<\/strong>To display all the images present in our system enter the below command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true\">$ docker images<\/pre>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker3.jpg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11022\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker3.jpg.png\" alt=\"Docker Fundamentals\" width=\"903\" height=\"89\" \/><\/a><\/p>\n<h3>Run a docker image to start the Container<\/h3>\n<p><strong>-&gt;<\/strong>To run an image using the below command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true\">$ docker run &lt;image name&gt;<\/pre>\n<h3>Display running Containers<\/h3>\n<p><strong>-&gt;<\/strong>We can list all the containers which are alive using the below command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true \">$ docker ps<\/pre>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker4.jpg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11023\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker4.jpg.png\" alt=\"Docker Fundamentals\" width=\"994\" height=\"129\" \/><\/a><\/p>\n<p><strong>-&gt;<\/strong>To get a detailed view of containers that are alive and excited, we can use the below command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true\">$ Docker ps -a<\/pre>\n<h3>Opening a Container<\/h3>\n<p><strong>-&gt;<\/strong>To enter into a container and execute commands, we can use the below command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true\">$ docker run -it &lt;imagename&gt; sh\/bash<\/pre>\n<p><strong>-&gt;<\/strong>You can also use the below command if there is an active container running in Docker. We will get container Id from <strong>$ docker ps<\/strong> command.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true \">$ docker exec -it &lt;container ID&gt; sh\/bash<\/pre>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker5.jpg.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11024\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker5.jpg.png\" alt=\"Docker Fundamentals\" width=\"781\" height=\"213\" \/><\/a><\/p>\n<h3>Stop a Container<\/h3>\n<p><strong>-&gt;<\/strong>To stop the container we can use the below command<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true\">$ docker stop &lt;container ID&gt;<\/pre>\n<h3>Clear all stopped Containers<\/h3>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-11025\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/docker6.png\" alt=\"Docker Fundamentals\" width=\"702\" height=\"232\" \/><\/a><\/p>\n<h3>Deleting an Image<\/h3>\n<p><strong>-&gt;<\/strong>To delete an image we can use the below command. Image ID can be found in the $ docker images command output.<\/p>\n<pre class=\"nums:false nums-toggle:false lang:default decode:true \">$ docker rmi &lt;image ID&gt;<\/pre>\n<h3 id=\"conclusion\"><strong>5. Conclusion<\/strong><\/h3>\n<p>Customer experiences can make or break a company. In this fast world, software development is advancing at lightning speed, and program managers are coming up with new ideas to develop and deploy software applications easily, and quickly.<\/p>\n<p>One of the biggest problems developers usually face is dependency hell, i.e., the application works perfectly fine on the dev\u00a0environment, but when deployed into QA\/production environment, the application throws errors. This is because it does not work, leaving developers with a huge problem to find the cause of the problem and what is missing exactly. Docker eliminates this problem by providing a complete execution guarantee, as everything needed to run the application is already present inside the container, which is an isolated environment and is not dependent on the underlying platform.<\/p>\n<p>If you want to learn more about Docker, here is a link to <a href=\"https:\/\/blog.cloudthat.com\/getting-started-with-docker-on-azure\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=getting-started-with-docker-on-azure\/\" target=\"_blank\" rel=\"noopener\"><strong>Getting Started with Docker on Azure.<\/strong><\/a><\/p>\n<h3 id=\"aboutcloudthat\"><strong>6. About CloudThat<\/strong><\/h3>\n<p><a href=\"https:\/\/www.cloudthat.com\/\"><strong>CloudThat\u00a0<\/strong><\/a>is\u00a0the official Microsoft Gold Partner, AWS Advanced Consulting Partner, and Training partner helping people develop knowledge on cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build\u00a0a robust\u00a0cloud computing ecosystem by disseminating\u00a0knowledge on technological intricacies within the cloud space.\u00a0Our blogs, webinars,\u00a0case studies, and white papers\u00a0enable all the stakeholders in the cloud computing sphere.<\/p>\n<p>Feel free to drop a comment or any queries regarding React-Redux, cloud adoption, consulting and we will get back to you quickly. To get started, go through\u00a0our\u00a0<a href=\"https:\/\/www.cloudthat.com\/expert-advisory\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=expert-advisory\"><strong>Expert Advisory\u00a0<\/strong><\/a>page\u00a0and\u00a0<a href=\"https:\/\/www.cloudthat.com\/managed-services-packages\/\"><strong>Managed Services Package<\/strong><\/a><strong>\u00a0<\/strong>that is\u00a0<a href=\"https:\/\/cloudthat.com\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=cloudthat.com\/\"><strong>CloudThat<\/strong><\/a><strong>&#8216;s<\/strong>\u00a0offerings.<\/p>\n<h3 id=\"faqs\"><\/h3>\n","protected":false},"author":281,"featured_media":11181,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3624,3892],"user_email":"pattan.i@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/11019"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/281"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=11019"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/11019\/revisions"}],"predecessor-version":[{"id":41162,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/11019\/revisions\/41162"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=11019"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=11019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}