{"id":381366,"date":"2021-12-15T16:03:14","date_gmt":"2021-12-15T13:03:14","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/"},"modified":"2021-12-15T16:03:14","modified_gmt":"2021-12-15T13:03:14","slug":"how-to-use-docker-to-safely-try-out-software-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/","title":{"rendered":"#How to Use Docker to Safely Try Out Software \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a326c97c547f\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a326c97c547f\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Why_Use_Docker_to_Try_Software\" >Why Use Docker to Try Software?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Finding_Docker_Images\" >Finding Docker Images<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Using_an_Image\" >Using an Image<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#What_If_Theres_No_Image\" >What If There\u2019s No Image?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Taking_Snapshots\" >Taking Snapshots<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Cleaning_Up\" >Cleaning Up<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Persistent_Data\" >Persistent Data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-use-docker-to-safely-try-out-software-cloudsavvy-it\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Use Docker to Safely Try Out Software \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage aligncenter size-full wp-image-14169\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/09\/993634a1.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/09\/993634a1.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/09\/993634a1.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"1200\" height=\"675\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Docker lets you package up software as self-sufficient containers that share their host\u2019s kernel but look and feel like independent VMs. The software within runs with near-native performance. This makes Docker containers a great way to safely try out new packages without installing them \u201cbare metal\u201d on your machine. Here\u2019s some of the techniques you can use.<\/p>\n<h2 id=\"why-use-docker-to-try-software\"><span class=\"ez-toc-section\" id=\"Why_Use_Docker_to_Try_Software\"><\/span>Why Use Docker to Try Software?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Installing directly from a package manager isn\u2019t always desirable when you\u2019re trying software for the first time. You might not want to run an unproven daemon or network service on your hardware. Some uninstallers won\u2019t remove every file connected to their package, leaving your machine cluttered with orphaned configs if you decide you won\u2019t use the software long-term.<\/p>\n<p>In a worst case scenario, the package you <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">download<\/a> could even be malicious or compromised. Opting for a bare metal installation puts your data at risk. By the time you\u2019re aware of a problem, attackers could already have gleaned sensitive information from their nefarious install script.<\/p>\n<p>Docker containers give you an isolated sandbox where you can install new packages without worrying about these concerns. Compared to spinning up a whole new VM, Docker is lighter and quicker but offers a similar level of security when configured for safe execution.<\/p>\n<p>Packages you install within a container will modify that container\u2019s filesystem, leaving your host\u2019s data intact. Malicious packages will have a much tougher time compromising your system as they\u2019ll need to break out of the container to reach your host. Installers that go looking for interesting config files from other packages will see a fresh filesystem instead of your user data.<\/p>\n<p>If it turns out a package isn\u2019t right for you, \u201cuninstall\u201d it by simply deleting your sandboxed Docker container. There\u2019ll be no trace of it left on your system.<\/p>\n<h2 id=\"finding-docker-images\"><span class=\"ez-toc-section\" id=\"Finding_Docker_Images\"><\/span>Finding Docker Images<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When you\u2019re looking to try something new, it\u2019s best to first search <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/hub.docker.com\">Docker Hub<\/a> and see whether there\u2019s already a container image for your chosen package. Images provide ready-to-use deployments of specific software, similar to a VM ISO that\u2019s been preconfigured with a set of packages.<\/p>\n<p>Many popular projects now offer official Docker images as part of their releases. These are clearly marked on Docker Hub with a green \u201cOfficial Image\u201d badge.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14988\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/12\/e6c009bb.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"775\" height=\"355\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Sometimes you might find an unofficial image that provides the package you\u2019re looking for but is published by a community member. It\u2019s worth checking the download stats first to assess whether others are successfully using it.<\/p>\n<p>You should also make sure the image has a variant for the software version you want. Images will distinguish different versions using Docker tags, such as <code>mongo:5<\/code> for MongoDB 5 and <code>mongo:4<\/code> for MongoDB 4. Use Docker Hub\u2019s Tags view to see the options available and when they were last updated.<\/p>\n<h2 id=\"using-an-image\"><span class=\"ez-toc-section\" id=\"Using_an_Image\"><\/span>Using an Image<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Once you\u2019ve found an image, <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.howtogeek.com\/733522\/docker-for-beginners-everything-you-need-to-know\/\">start a container<\/a> from it. You should refer to your image\u2019s description on Docker Hub to get specific instructions for the software you\u2019ve selected.<\/p>\n<p>In <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a>, images packaging an interactive application can be started using this sequence:<\/p>\n<pre>docker run -it example-image:latest<\/pre>\n<p>Start images that provide background processes with the <code>-d<\/code> flag instead:<\/p>\n<pre>docker run -d example-image:latest<\/pre>\n<p>The <code>docker run<\/code> command starts a container using the specified image. Your software is now running in an isolated environment with its own filesystem. You can run several independent instances simultaneously by starting multiple containers from the image.<\/p>\n<h2 id=\"what-if-theres-no-image\"><span class=\"ez-toc-section\" id=\"What_If_Theres_No_Image\"><\/span>What If There\u2019s No Image?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The absence of an official \u2013 or unofficial \u2013 Docker image for your chosen software package isn\u2019t the end of your try-with-Docker journey. In this situation, create a container from an operating system base image to host your isolated environment. You can then run the software\u2019s regular installation procedure to get it into your container.<\/p>\n<p>Here\u2019s an example that starts a fresh Ubuntu environment in Docker:<\/p>\n<pre>docker run -it ubuntu:20.04<\/pre>\n<p>The <code>-it<\/code> flags mean you\u2019ll be dropped into an interactive shell running within the terminal. Now you can use <code>apt<\/code>, <code>curl<\/code>, <code>wget<\/code>, or any other necessary steps to install and try your target package.<\/p>\n<pre>apt update&#13;\napt install example-package&#13;\nexample-package --example-flags<\/pre>\n<p>If you\u2019ll want to repeat these steps again in the future, write a Dockerfile that lets you build your own image:<\/p>\n<pre>FROM ubuntu:20.04&#13;\napt update&#13;\napt install example-package&#13;\nENTRYPOINT [\"example-package\"]&#13;\nCMD [\"\"]<\/pre>\n<p>Build your image:<\/p>\n<pre>docker build -t example-package:latest .<\/pre>\n<p>Now use your image to start a container that automatically runs the <code>example-package<\/code> binary added to the Ubuntu base image:<\/p>\n<pre>docker run -it example-package:latest --example-flags<\/pre>\n<p>This works because the binary is set as the Docker image\u2019s command in your Dockerfile. It\u2019ll run automatically when the container starts, receiving the flags you pass to <code>docker run<\/code>.<\/p>\n<h2 id=\"taking-snapshots\"><span class=\"ez-toc-section\" id=\"Taking_Snapshots\"><\/span>Taking Snapshots<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Another benefit of using Docker to try new software is its ability to create snapshots of a container\u2019s current state. This is useful when you\u2019re trialing different settings and want to backup a specific configuration so you can easily return to it later.<\/p>\n<p>Use the <code>docker commit<\/code> command to create a new image from a container\u2019s filesystem:<\/p>\n<pre>docker commit my-container package-snapshot:latest<\/pre>\n<p>You should substitute <code>my-container<\/code> with the ID or name of your container. You can get these details by running <code>docker ps<\/code> which shows all running containers in the order they were started. The command will tag the snapshotted image as <code>package-snapshot:latest<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-10029\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/bc995211.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"872\" height=\"147\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Now you can apply any changes you need to your existing container without worrying about breaking your current state. If you want to rollback, use <code>docker run<\/code> to start another container from the <code>package-snapshot:latest<\/code> image.<\/p>\n<h2 id=\"cleaning-up\"><span class=\"ez-toc-section\" id=\"Cleaning_Up\"><\/span>Cleaning Up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When you\u2019ve finished experimenting, Docker makes it easy to \u201cuninstall\u201d your software without leaving a trace. First delete your containers:<\/p>\n<pre>docker rm my-container<\/pre>\n<p>Then clear the images you\u2019ve downloaded:<\/p>\n<pre>docker rmi example-image:latest<\/pre>\n<p>You\u2019re now back to a clean state. As anything related to the software existed only inside your container, your host\u2019s filesystem will be left unaltered.<\/p>\n<h2 id=\"persistent-data\"><span class=\"ez-toc-section\" id=\"Persistent_Data\"><\/span>Persistent Data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>One challenge you might encounter is when you want to pause your trials and resume them later. Docker containers reset their state when they\u2019re stopped so any filesystem changes you\u2019ve made, such as adding config files, will be lost.<\/p>\n<p>You can solve this by mounting volumes into the container so that important files are persisted on your host. Use the <code>-v<\/code> flag with <code>docker run<\/code> for this.<\/p>\n<pre>docker run -it -v config-volume:\/etc\/example-package\/conf.d example-package:latest<\/pre>\n<p>Volumes outlive individual containers so you can restore your files into a new container by supplying the same <code>-v<\/code> flags. Delete volumes with the <code>docker volume rm<\/code> command.<\/p>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Docker is a quick and easy way to safely try out software without polluting your host machine\u2019s environment. It lets you triage new packages ahead of introducing them to sensitive systems and bare metal hardware.<\/p>\n<p>Using Docker provides an opportunity to scan software before you run it. The built-in Docker Scan component identifies vulnerabilities in the packages within an image, giving you an overview of the security implications. Use <code>docker scan example-package:latest<\/code> to scan downloaded images.<\/p>\n<p>You could choose to keep using your Dockerized software installation after your initial experimentation. Alternatively, you can use what you\u2019ve learned to set up a functioning bare metal install with increased confidence that the package does what it claims to.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/14986\/how-to-use-docker-to-safely-try-out-software\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Use Docker to Safely Try Out Software \u2013 CloudSavvy IT&#8221; Docker lets you package up software as self-sufficient containers that share their host\u2019s kernel but look and feel like independent VMs. The software within runs with near-native performance. This makes Docker containers a great way to safely try out new packages without installing&#8230;<\/p>\n","protected":false},"author":1,"featured_media":381367,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/09\/993634a1.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-381366","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/381366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=381366"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/381366\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/381367"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=381366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=381366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=381366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}