{"id":21629,"date":"2023-01-19T13:14:29","date_gmt":"2023-01-19T12:14:29","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=21629"},"modified":"2024-09-11T15:01:31","modified_gmt":"2024-09-11T13:01:31","slug":"containers-for-developers","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/","title":{"rendered":"Docker Containers for Developers"},"content":{"rendered":"\n<p>As I am working on developing a component for <a href=\"https:\/\/www.dbi-services.com\/products\/yak\/\" target=\"_blank\" rel=\"noreferrer noopener\">YaK<\/a>, I have to stick to standards on how to write code in Ansible as well as many other constraints regarding security. I always thought of docker being a server component that facilitate deployment and scaling, but it is much more than that: In this blog, I will use it on my laptop to run different tools to improve my code and, finally, server security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lint<\/h2>\n\n\n\n<p>Despite embedded constraints to have a consistent formatting, Ansible has some flexibility in how you can write the code that you could have difference between two components written by two different people. Thus &#8220;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Lint_(software)\" target=\"_blank\" rel=\"noreferrer noopener\">linter<\/a>&#8221; my code is a must to make it more consistent and more robust.<\/p>\n\n\n\n<p>Of course, it is possible to ensure that code is fine with <a href=\"https:\/\/gitlab.com\/yak4all\/yak\/\" target=\"_blank\" rel=\"noreferrer noopener\">gitlab<\/a> pipelines on on every commit or merge, but if you never linted your code and doing it on a whole component, you will have lots of failures and warnings to deal with. It is preferable to do it step by step, or better said, role by role.<\/p>\n\n\n\n<p>It is also possible to install ansible-lint inside <a href=\"https:\/\/gitlab.com\/yak4all\/yakenv\" target=\"_blank\" rel=\"noreferrer noopener\">yakenv<\/a> container, but packages dependencies might arise.<\/p>\n\n\n\n<p>The best solution I found, for the time being, was to use a container image provided by Ansible developers: <a href=\"https:\/\/github.com\/ansible\/creator-ee\" target=\"_blank\" rel=\"noreferrer noopener\">ansible creator<\/a>.<\/p>\n\n\n\n<p>With this image, we have the benefit that comes with containers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>we do not touch our yakenv image<\/li>\n\n\n\n<li>it is fully functional out of the box, or out of the container :).<\/li>\n\n\n\n<li>it is updated and maintained by the community<\/li>\n<\/ul>\n\n\n\n<p>Starting the container is easy as triggering the command below and mapping the volume to my GIT repo:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker run --rm -it -v \/home\/ols\/GIT:\/data ghcr.io\/ansible\/creator-ee\n<\/pre><\/div>\n\n\n<p>Next, in the container, we can simply find all files to lint to ansible-lint like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n$ cd \/data\/components\/weblogic_domain\n$ ansible-lint --offline\n<\/pre><\/div>\n\n\n<p>A summary of analyze will be shown at end of report:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nFailed after min profile: 16 failure(s), 27 warning(s) on 148 files.\n<\/pre><\/div>\n\n\n<p>As you can see, there is lots of work to do. This is why I prefer to do it role by role:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nansible-lint --offline roles\/common\/jdk-install\/\n<\/pre><\/div>\n\n\n<p>Once all issues and warnings have been resolved, it is possible to enable a pre-commit hook that will automatically lint the code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Security Scanning<\/h2>\n\n\n\n<p>Even it is delivered without any warranty, I like to run <a href=\"https:\/\/testssl.sh\/\" target=\"_blank\" rel=\"noreferrer noopener\">testssl.sh<\/a> script to avoid bad configuration on SSL part of the component. As for ansible-lint, I could install it inside YaK container or on the target server to run, but there is another solution: Use of pre-configured <a href=\"https:\/\/hub.docker.com\/r\/drwetter\/testssl.sh\" target=\"_blank\" rel=\"noreferrer noopener\">container<\/a> with all necessary libraries like openssl, for example.<\/p>\n\n\n\n<p>Running this container is also very easy:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\ndocker run --rm -ti drwetter\/testssl.sh https:\/\/&lt;server ip&gt;:8443\n<\/pre><\/div>\n\n\n<p>The last argument is the URL to test. Then, it will run for about 5 minutes and test protocols, ciphers, certificate, HTTP responses and few known vulnerabilities. It will also simulate many different clients and Operating Systems.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Next?<\/h2>\n\n\n\n<p>Containerizing client application are great. And it works on <a href=\"https:\/\/en.wikipedia.org\/wiki\/Windows_Subsystem_for_Linux\" target=\"_blank\" rel=\"noreferrer noopener\">WSL<\/a> without any difference as on Linux (Thanks containers!). Nevertheless, analyzing, understanding and resolving generated reports still requires a certain level of expertise.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/ansible\/creator-ee\" target=\"_blank\" rel=\"noreferrer noopener\">ansible creator<\/a> comes also with <a href=\"https:\/\/molecule.readthedocs.io\/en\/latest\/\" target=\"_blank\" rel=\"noreferrer noopener\">molecule<\/a>, a testing framework, which I am also studying and might be in another blog post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I am working on developing a component for YaK, I have to stick to standards on how to write code in Ansible as well as many other constraints regarding security. I always thought of docker being a server component that facilitate deployment and scaling, but it is much more than that: In this blog, [&hellip;]<\/p>\n","protected":false},"author":109,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1321,1504],"tags":[2716,762,601],"type_dbi":[],"class_list":["post-21629","post","type-post","status-publish","format-standard","hentry","category-ansible","category-docker","tag-yak","tag-containers","tag-docker"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Docker Containers for Developers - dbi Blog<\/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:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Containers for Developers\" \/>\n<meta property=\"og:description\" content=\"As I am working on developing a component for YaK, I have to stick to standards on how to write code in Ansible as well as many other constraints regarding security. I always thought of docker being a server component that facilitate deployment and scaling, but it is much more than that: In this blog, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-19T12:14:29+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-11T13:01:31+00:00\" \/>\n<meta name=\"author\" content=\"DevOps\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DevOps\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\"},\"author\":{\"name\":\"DevOps\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735\"},\"headline\":\"Docker Containers for Developers\",\"datePublished\":\"2023-01-19T12:14:29+00:00\",\"dateModified\":\"2024-09-11T13:01:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\"},\"wordCount\":508,\"commentCount\":0,\"keywords\":[\"#yak\",\"Containers\",\"Docker\"],\"articleSection\":[\"Ansible\",\"Docker\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\",\"name\":\"Docker Containers for Developers - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2023-01-19T12:14:29+00:00\",\"dateModified\":\"2024-09-11T13:01:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Docker Containers for Developers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735\",\"name\":\"DevOps\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g\",\"caption\":\"DevOps\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/devops\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Docker Containers for Developers - dbi Blog","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:\/\/www.dbi-services.com\/blog\/containers-for-developers\/","og_locale":"en_US","og_type":"article","og_title":"Docker Containers for Developers","og_description":"As I am working on developing a component for YaK, I have to stick to standards on how to write code in Ansible as well as many other constraints regarding security. I always thought of docker being a server component that facilitate deployment and scaling, but it is much more than that: In this blog, [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/","og_site_name":"dbi Blog","article_published_time":"2023-01-19T12:14:29+00:00","article_modified_time":"2024-09-11T13:01:31+00:00","author":"DevOps","twitter_card":"summary_large_image","twitter_misc":{"Written by":"DevOps","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/"},"author":{"name":"DevOps","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735"},"headline":"Docker Containers for Developers","datePublished":"2023-01-19T12:14:29+00:00","dateModified":"2024-09-11T13:01:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/"},"wordCount":508,"commentCount":0,"keywords":["#yak","Containers","Docker"],"articleSection":["Ansible","Docker"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/","url":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/","name":"Docker Containers for Developers - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2023-01-19T12:14:29+00:00","dateModified":"2024-09-11T13:01:31+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/containers-for-developers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Docker Containers for Developers"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/4cd1b5f8a3de93f05a16ab8d7d2b7735","name":"DevOps","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cdd2dd7441774355062c0f0f68612296b059cd1e2ff6c7af0b15dba0ed64a85f?s=96&d=mm&r=g","caption":"DevOps"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/devops\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/21629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/109"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=21629"}],"version-history":[{"count":8,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/21629\/revisions"}],"predecessor-version":[{"id":23211,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/21629\/revisions\/23211"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=21629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=21629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=21629"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=21629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}