{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"f7a13c08-6929-58c2-9d9e-eae3b357b1e1","frontmatter":{"category":"Coding","title":"Exploring technologies with Docker","date":"2018-12-19","summary":"Yet another use case for using containers.","thumbnail":{"relativePath":"pages/exploring-technologies-with-docker/thumbnailImage.png","childImageSharp":{"resolutions":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAZCAYAAAAxFw7TAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAHZklEQVQ4yx1VWVdaWRq9v6ueuh66U71WV7K6U9VVGYxG44SAmoCJiAoqYhRREZBJJkFmogIyyHABxQwaZZIZuXDh3ouVtiSzxtjXetjr2/vlO98+3zr7AGQzyT/govpJL0h+0hoxMOCkemmOwdRsmFOfATkI0zOGiSKiEkMdrdCUWXRYnUEGllPIoCKNXHO66lofIYNKnCviCNCiawVvLt0C/8G9Af59/gZ4W/qL7zb/l3Svqa9O1pGRu6K72GKEVxozFCut3EOMwI+jzZwDtJUbRbtx3s1P4PoQfTBzgD5TZFGAYiJ5hlwDnn5Lj5tk7HAPOalOpoOe4AZmUC44X530shH5a+Xxc8NRmaHJI+OruRo+WW1Uk62N6/I1uvKoSlenahPG49qYNlkDsBWS4+MazXlmppr/MDzWnJkHHBceVjTusxZH9NkKZy0HM7WJCk2RhPEG8KQ+j+sszNBco1BdcuznliKiChfkw1w/Hwa+aEihhrR158PyI+c3I9V6Jm3bPtcSM2nPOtS8kEG7eVGsdS6G4bYw3CbWvRjHHuLWcdtY80y8LvTEC0zPENoia8FGPSMY0FB22z/r+pwfV4imhpqo/qAhO75vDEcTbmuBqshVxlZzME1xBD+Tp2CGtohPWYSfLR/BQ6o0PKwqVAX2N1neNrcy6Z2CuSAXBk6XO2znRqr9k5a80VAR1j9ryesXDvbhqX22WndJKu/couo730p+ZXu1wI8oqsJtcWXeFoSm9MfwKN58xRLONPzz5Y8RGVx3z8HARw0peCptw9Eaaii6wv8TPQg09AOZ95bhk08vRtAzHaV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mra9Kc9YSxLGWy3JLKB0LC0qpfVV5z78IAQ1Vj/9Peaf/dLk90FASwFNJ61bDSEt9eME4udgYRT6ZnmJX4GJBujNf7LeSscENYo3j9MMkfgptmouhRvt+/soxUftkGUW/2SYR4Lum3XehbPady5t831St/nPZ3a1L3PL5Gr2ON6x9MV83FBRlO0vFPhMFG1x7XJvdjMBE/H7vc9Ko2RbLXW1O1D5bGMilHX/LVt6sJbC6YvGpFRavWmnxKJcNu+sv9nCr8BvnZmnPtVl+aVvPKMKynD5nLGsSqpLAZzmWgC8hgT8CrQbsucTOUin5Sg7t+XgQ8K/xaOAGMx74eSIR+JF+AP6NHvU1L6SzJGn+3SN+uv6Ql/lj3AjBHN8cMuygn1DM1PrTDcoJw0WrPzET67TNZydUG/2k00Cus0KcE+C3yT3/zyOv/LfHX/tv0CKBn2i7vgczb9928aK5B9P76XtT+zn8Q9obc0/EiMaeXJuyLdOh6cyQjX2Z5uWWTI+BmCHpiJn7knuZcS8zAzRNhgO94nSAvJQMdC3G/QRBIkAUJn04vJ28mJcgTAWb2WFdr/7J2vTe8wADZHjHtse87F22dxQc9bJ2WV7WNh4RYYZ3yDnk/T90eFLdjx6IqwAAAABJRU5ErkJggg==","width":265,"height":325,"src":"/static/753d78469abf65ded853c2e0d4fb7aec/b3029/thumbnailImage.png","srcSet":"/static/753d78469abf65ded853c2e0d4fb7aec/b3029/thumbnailImage.png 1x,\n/static/753d78469abf65ded853c2e0d4fb7aec/8d141/thumbnailImage.png 1.5x"}}},"authorName":"Marcin Sałata","authorDescription":"Marcin is Senior Software Engineer at AUTO1 Group.","authorAvatar":{"relativePath":"pages/exploring-technologies-with-docker/avatar.png","childImageSharp":{"resolutions":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsSAAALEgHS3X78AAACyElEQVQ4y4VUO2gUURR9mZmN8YcItoKVjeXuzsxu9jOzm92NkBBTqDEmjZAEgtqIpSgI1gp+uhS6kEI7wc7GQsFCLERiISGCaGHhF02yu+M5s/cujyC4cJY379573r3n3XdNvV51xsYiJ4rKbqlUyBj8wjAYyWazp4BVYB3YAraBDeAhMBcE/l76lkrFTLVachuNyCGXEbJMrVbx6ADnaWAtn88nvu8nWBMdQcJ9Auv3wCxjWq2aC9IMSF3DzCyyG1YAs9pSYkL2melmLpfT71tKGkUlz2iZJAuCgA5dEjGAwPoV0AbuAy+tfR7YkZjb5CiXR1OutEw5jWQdCfgCnEiSxNg/7LWAj+KTSiHSzBvrAtascrriPCmnDkP4AYQ0Em3TGPHf8P38ARpP/4PsHQ7aU69Hqdi4OJeI47JXLg9IX1tVbUuWCzSsygcJO+L0goGNRpySoB1colarerhEvcCn4tuxCB/TsC5ZdS3Ct2Ho75uZmRoigWbIbgCxt7Q0O8TLsgg17o2R2+JHzzJcV/1IoBlybel42SLsCcc3I6UqoaZ+lUHFYjjCzJSQa+4J4UVLKiX8ScOGVXJXDN+xd7SfZXFYS65U+n2Wz+cOw+ezHadSkfCRdVJiZdlmMG9ZtHMpgWR3Z0eMSvWExjmrbXoCbZ951dIim7Yk6u1IYtlwavChW51Pp01tXOwf01eC9RHs/Rbbnx2Hf4IUh/Q5zdol8H3KG22Pj9edOK54LF1876pd37TELhqdZ+J4MwxDHUvXgDOFQrB7YqLpjI4WdhG8GLYNbCeBK/1+TWNWRG+Pfy5Hj5Dek3IXzX9+8DkL/AIeLC/PDU1NHXdSQk5altNsDkjPAT+ArzKyFnK5bB2IxbYik4hanmfM5GTL6Q/Y2DUc25y0HLToubR8TI39cL4APJOxr/35AXgOXEJnHKQvepP6eiQj119kDrZjqLo8HAAAAABJRU5ErkJggg==","width":50,"height":50,"src":"/static/26a7a327ccc4b335712e5a7086f2b26d/45876/avatar.png","srcSet":"/static/26a7a327ccc4b335712e5a7086f2b26d/45876/avatar.png 1x,\n/static/26a7a327ccc4b335712e5a7086f2b26d/eb85b/avatar.png 1.5x,\n/static/26a7a327ccc4b335712e5a7086f2b26d/4f71c/avatar.png 2x,\n/static/26a7a327ccc4b335712e5a7086f2b26d/9ec3e/avatar.png 3x"}}},"headerImage":{"relativePath":"pages/exploring-technologies-with-docker/headerImage.png","childImageSharp":{"resolutions":{"base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAYAAADDl76dAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABsUlEQVQY0zWR32/SUBiG+x8bM0IJMp2BjQ3SKgzTFlpWKG0puBloOefwQ5jbUDezC70wu9minO87JE6N/gPWYuLt+zwX7/t9kuacrpvtC9EgNjyhJeFRBX2mwg4rr+vkCDZs4/z3NtkOOxAdUgHTX6BpX6zr0RE8HZexTRQhxWQPf4Q6WCdDyHofYD42VqcT42vWu8RNdj80ICZFjOkufg81ME/Cf96CNlfxpMB/hi+weTyAR/41TEZNLrlsFytkHzPdN5Bu3IpMdwnp3lv+wPgittz3UKMl6LACBqSEhyMVMv4ZbJk3Qu4vwKEKV6PnmPLeYca6wYfdBUra9ADLkyLk+jOQzVvMutdQda94rXUlDNJa5V8X4ZBVMNWbY7r1CbdfTrkyqqBFNFCDBa+6c2FQe5VnNTAjA6WY5fFbMkXrjyHrfkSawD/jIv891NF5dQy57mUyTwdKrIR/BqPP4D6qQjzO8zhp+GvQwPbGC5YwpwaXnA4TPWcmbGLxXKhgMHoGEStwPdxH2TvHVP1OPA6m6EYqbkcK2smdgvZMuD7FAd0DPSwK2VtiunEn5ORJfwFIJFacA7WGDwAAAABJRU5ErkJggg==","width":1280,"height":392,"src":"/static/be0acc48b4db44e7e3d00e2d5c353dc3/26421/headerImage.png","srcSet":"/static/be0acc48b4db44e7e3d00e2d5c353dc3/26421/headerImage.png 1x,\n/static/be0acc48b4db44e7e3d00e2d5c353dc3/34a7a/headerImage.png 1.5x"}}}},"html":"<h2>tl;dr</h2>\n<p>Using Docker Compose we are able to quickly set up complex environments consisting of multiple containers, which allows to speed up software evaluation process.</p>\n<h2>Intro</h2>\n<p>Things evolving quickly, tools come and go, last year cutting edge is often legacy now. Dozens of new tools emerges every month\nand approach for being up to date also needs to evolve.</p>\n<p>Containers on production with all its benefits and challenges is a common thing nowadays, but do not forget that containers could also help us in other use cases. One of them is to improve technologies evaluation process. </p>\n<h2>Docker at home</h2>\n<p>Many moons ago when new fancy tool was released and looks so promising to give it a try options were limited - build it from sources, use installer or package manager. Giving a try for new promising tool was quite time consuming. Steps required to download, install, configure system and dependencies were usually not most exciting part of evaluating new message broker or database. Now containers or PaaS solutions allow us to shift focus directly from setup to features that particular products offers.</p>\n<h2>Level 1: Basic usage</h2>\n<p>Using Docker one terminal command is enough to download, run and evaluate interesting applications.</p>\n<div class=\"gatsby-highlight\" data-language=\"shell\"><pre class=\"language-shell\"><code class=\"language-shell\">docker run postgres</code></pre></div>\n<p>Above example command will pull latest version of <a href=\"https://hub.docker.com/_/postgres\">PostgreSQL</a> image from <a href=\"https://hub.docker.com\">Docker Hub</a> and run it locally. This is a quick and straightforward way of running hundreds of interesting applications. Container will run in sandbox environment, so we do not need to think about operation system settings and other specific configuration that may be required with standard installation. Although it is a simpler way than using installers or building from sources, then comparing to common package managers where also one command is usually enough, user experience looks quite similar.</p>\n<h2>Level 2: Next step</h2>\n<p>The real benefits of using Docker in local environment we can observe if we would like to build some complex environment that contains multiple applications linked together as usually things are more complicated than just running a database or monitoring tool separately. Challenge often starts when we would like to evaluate a monitoring tool that needs a datasource and entire environment should be relatively easily to set up and manage. That is where <code class=\"language-text\">Docker Compose</code> comes to help. </p>\n<p>As stated in <a href=\"https://docs.docker.com/compose\">official documentation</a> Compose is a tool that allow us to define and run multi-container applications. Using it in most common scenarios comes down to creating YAML file with required images and configurations. </p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">version</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'3'</span>\n<span class=\"token key atrule\">services</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">myService1</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> service1\n    <span class=\"token punctuation\">{</span>configuration<span class=\"token punctuation\">:</span><span class=\"token punctuation\">}</span>\n  <span class=\"token key atrule\">myService2</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> service2\n    <span class=\"token punctuation\">{</span>configuration<span class=\"token punctuation\">:</span><span class=\"token punctuation\">}</span></code></pre></div>\n<p>Having <code class=\"language-text\">docker-compose.yml</code> file ready we are able to start it with one terminal command.</p>\n<div class=\"gatsby-highlight\" data-language=\"shell\"><pre class=\"language-shell\"><code class=\"language-shell\">docker-compose up</code></pre></div>\n<p>Docker will build or download all necessary images, set up necessary configurations, networks and run defined containers for us.</p>\n<h2>Level 3: Hands-on experience</h2>\n<p> In below example we would like to see in action <a href=\"https://hub.docker.com/r/grafana/grafana\">Grafana</a> - open source monitoring tool with <a href=\"https://hub.docker.com/_/postgres\">PostgreSQL</a> as datasource. </p>\n<h3>Define PostgreSQL</h3>\n<p>First thing w need to do is to create empty <code class=\"language-text\">docker-compose.yml</code> file and add PostgreSQL as datasource.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">version</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'3'</span>\n<span class=\"token key atrule\">services</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">myDatasource</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> postgres</code></pre></div>\n<p>Above we have defined one service called <code class=\"language-text\">myDatasource</code> that will be created using <code class=\"language-text\">postgres</code> image.</p>\n<h3>Define Grafana</h3>\n<p>Having our datasource configured we can extend our Compose file with second service - Grafana.</p>\n<div class=\"gatsby-highlight\" data-language=\"yaml\"><pre class=\"language-yaml\"><code class=\"language-yaml\"><span class=\"token key atrule\">version</span><span class=\"token punctuation\">:</span> <span class=\"token string\">'3'</span>\n<span class=\"token key atrule\">services</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">myDatasource</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> postgres\n  <span class=\"token key atrule\">myMonitoring</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">image</span><span class=\"token punctuation\">:</span> grafana/grafana\n    <span class=\"token key atrule\">ports</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> 3000<span class=\"token punctuation\">:</span><span class=\"token number\">3000</span></code></pre></div>\n<p>Above we have defined second service called <code class=\"language-text\">myMonitoring</code> that will be created using <code class=\"language-text\">grafana/grafana</code> image.\nAdditionaly to basic service definition we have also exposed port 3000, so Grafana user interface can be access from outside the container.</p>\n<h3>Troubleshooting</h3>\n<p>At this point we have configured our environment, so by running <code class=\"language-text\">docker-compose up</code> two containers should be configured and run by Docker.\nThen navigating to <code class=\"language-text\">localhost:3000</code> will allow us to access Grafana web interface where datasource could be set up.\nThing that is worth notice is that if we would like to configure our PostgreSQL datasource with default suggested <code class=\"language-text\">Host - localhost:5432</code></p>\n<p><a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/0dbbf0ff0acaaaf0a5714c155ad1d684/72b46/DatasourceConfig.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-wrapper\"\n    style=\"position: relative; display: block;  max-width: 448px; margin-left: auto; margin-right: auto;\"\n  >\n    <span\n      class=\"gatsby-resp-image-background-image\"\n      style=\"padding-bottom: 45.53571428571428%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsSAAALEgHS3X78AAABiElEQVQoz32SWVPCQBCEeUCOQCABckIqJzfIES3EAqEU5ZLy//+admYDllrKw1fJZnd6ejuTWixX2B+OgtPpA4vlGpvXHd62exyP7xjejlDTDBimDd2wrqLpJlJhs4P4bobb0RSd7gCeF8LzQwRhk4hg1x2olRoqV+D9ak0Xoqlmq4+H+RNM24XjNqmLBUVRoapVQbWqoVgsQZKK/5LPF1Aqq+IWqSBsYxLP6GpT+PRumHXqmghdREslBbJc/oIb/F4rSiVx2O4O8bzZYbXeIIi69LEuxAzDpGto0DRdFGUyOQG7KRRk8fxO+eIwavUwntxTVh68IHHIrlgkKZTQcHw8LtaC/nBCZ12RXY1yu0TCNcJhGHXoh8RUFMD1W0JQoW4sxsh02LQaGFFTjiY4x8Ji/FdZkCPhBkJwQNm9bA7Y7k/oDcbQ6fBoHGM2myPwI2SzeeRyEtLpGyIDnUbIsmyKwxCCzI+xqTdcchbBpXFpOB5t2JSfRa4SF+p5LCrkhOGZ/Evosv4E7kLsTTjvj+sAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n    ></span>\n    <img\n        class=\"gatsby-resp-image-image\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;box-shadow:inset 0px 0px 0px 400px white;\"\n        alt=\"Datasource Config\"\n        title=\"\"\n        src=\"/static/0dbbf0ff0acaaaf0a5714c155ad1d684/72b46/DatasourceConfig.png\"\n        srcset=\"/static/0dbbf0ff0acaaaf0a5714c155ad1d684/762ef/DatasourceConfig.png 148w,\n/static/0dbbf0ff0acaaaf0a5714c155ad1d684/c91c8/DatasourceConfig.png 295w,\n/static/0dbbf0ff0acaaaf0a5714c155ad1d684/72b46/DatasourceConfig.png 448w\"\n        sizes=\"(max-width: 448px) 100vw, 448px\"\n      />\n  </span>\n  </a></p>\n<p>We will end up with following error message:</p>\n<div class=\"gatsby-highlight\" data-language=\"markdown\"><pre class=\"language-markdown\"><code class=\"language-markdown\">dial tcp 127.0.0.1:5432: connect: connection refused</code></pre></div>\n<p>This is happening because Compose creates network for our application and inter container communication happens via services names.\nIn our example using <code class=\"language-text\">myDatasource:5432</code> as <code class=\"language-text\">Host</code> solves connection issue.</p>\n<h2>Further explorations</h2>\n<p>This relatively simple example consisting of two containers can be considered as a base for further journeys in world of containers.\nPublic cloud providers offers multiple services like <a href=\"https://aws.amazon.com/ecs\">Amazon Elastic Container Service</a> or <a href=\"https://azure.microsoft.com/en-us/services/kubernetes-service\">Azure Kubernetes Service</a>\nwhich can be utilised as next step in building container based environments.</p>","fields":{"slug":"/exploring-technologies-with-docker/","tags":["docker","compose","grafana"]}}}]}},"pageContext":{"slug":"/tags/compose","tag":"compose","categories":["Architecture","Coding","DevOps","Engineering","ProjectManagement","QA","Social","TechRadar"]}}