{"id":2273,"date":"2018-04-11T07:00:39","date_gmt":"2018-04-11T01:30:39","guid":{"rendered":"http:\/\/www.upnxtblog.com\/?p=2273"},"modified":"2020-04-23T10:59:04","modified_gmt":"2020-04-23T05:29:04","slug":"create-docker-images-using-multi-stage-builds","status":"publish","type":"post","link":"https:\/\/www.upnxtblog.com\/index.php\/2018\/04\/11\/create-docker-images-using-multi-stage-builds\/","title":{"rendered":"Docker tutorial &#8211; Create Docker Images using Multi-stage builds"},"content":{"rendered":"<div class='booster-block booster-read-block'><\/div><p>From the last <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2017\/09\/07\/10-things-know-containerization-technology\/\">post<\/a>, we have understood what is container &amp; why do we use containers in general. Just to recap here are some of the key points<\/p>\n<ul>\n<li><strong>Containers are an abstraction at the app layer<\/strong> that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in userspace. Containers take up less space than VMs (container images are typically tens of MBs in size) and start almost instantly.<\/li>\n<li>A <strong>container image<\/strong> is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings.<\/li>\n<li><strong>Containers run apps natively<\/strong> on the host machine\u2019s kernel. They have better performance characteristics than virtual machines that only get virtual access to host resources through a hypervisor. Containers can get native access, each one running in a discrete process, taking no more memory than any other executable.<\/li>\n<\/ul>\n<p>In this post, we are going to take look at optimizing the images using multi-stage builds. Multi-stage builds are a new feature requiring Docker <em>17.05<\/em> or higher on the daemon and client.<\/p>\n<p>This quickstart assumes basic understanding of Docker\u00a0<a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/\">concepts<\/a>, please refer to earlier posts for understanding on Docker &amp; how to <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/\">install<\/a> and containerize <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/19\/docker-tutorial-build-docker-image-for-your-angular-6-application\/\">applications<\/a>.<\/p>\n\n<h2>Why Multi-stage builds?<\/h2>\n<p>In your project, you would have two or more Dockerfiles i.e., one for Development and another one for Production. One file would have the steps to build the binary and artifacts using a development container, the second would be optimized for production and not include any of the development tools.<\/p>\n<p>With a multi-stage builds feature, you can use multiple <code class=\"highlighter-rouge\">FROM<\/code>\u00a0statements in your Dockerfile. Each\u00a0<code class=\"highlighter-rouge\">FROM<\/code> instruction can use a different base, and each of them begins a new stage of the build. You can selectively copy artifacts from one stage to another, leaving behind everything you don\u2019t want in the final image. To show how this works, Let\u2019s adapt the Dockerfile from the previous section to use multi-stage builds. Example below :<\/p>\n<p><strong><code class=\"highlighter-rouge\">Dockerfile<\/code><\/strong>:<\/p>\n<div class=\"language-conf highlighter-rouge\">\n<div class=\"highlight\">\n<pre class=\"highlight\"><span class=\"n\">FROM<\/span> <span class=\"n\">golang<\/span>:<span class=\"m\">1<\/span>.<span class=\"m\">7<\/span>.<span class=\"m\">3<\/span>\r\n<span class=\"n\">WORKDIR<\/span> \/<span class=\"n\">go<\/span>\/<span class=\"n\">src<\/span>\/<span class=\"n\">github<\/span>.<span class=\"n\">com<\/span>\/<span class=\"n\">alexellis<\/span>\/<span class=\"n\">href<\/span>-<span class=\"n\">counter<\/span>\/\r\n<span class=\"n\">RUN<\/span> <span class=\"n\">go<\/span> <span class=\"n\">get<\/span> -<span class=\"n\">d<\/span> -<span class=\"n\">v<\/span> <span class=\"n\">golang<\/span>.<span class=\"n\">org<\/span>\/<span class=\"n\">x<\/span>\/<span class=\"n\">net<\/span>\/<span class=\"n\">html<\/span>  \r\n<span class=\"n\">COPY<\/span> <span class=\"n\">app<\/span>.<span class=\"n\">go<\/span> .\r\n<span class=\"n\">RUN<\/span> <span class=\"n\">CGO_ENABLED<\/span>=<span class=\"m\">0<\/span> <span class=\"n\">GOOS<\/span>=<span class=\"n\">linux<\/span> <span class=\"n\">go<\/span> <span class=\"n\">build<\/span> -<span class=\"n\">a<\/span> -<span class=\"n\">installsuffix<\/span> <span class=\"n\">cgo<\/span> -<span class=\"n\">o<\/span> <span class=\"n\">app<\/span> .\r\n\r\n<span class=\"n\">FROM<\/span> <span class=\"n\">alpine<\/span>:<span class=\"n\">latest<\/span>  \r\n<span class=\"n\">RUN<\/span> <span class=\"n\">apk<\/span> --<span class=\"n\">no<\/span>-<span class=\"n\">cache<\/span> <span class=\"n\">add<\/span> <span class=\"n\">ca<\/span>-<span class=\"n\">certificates<\/span>\r\n<span class=\"n\">WORKDIR<\/span> \/<span class=\"n\">root<\/span>\/\r\n<span class=\"n\">COPY<\/span> --<span class=\"n\">from<\/span>=<span class=\"m\">0<\/span> \/<span class=\"n\">go<\/span>\/<span class=\"n\">src<\/span>\/<span class=\"n\">github<\/span>.<span class=\"n\">com<\/span>\/<span class=\"n\">alexellis<\/span>\/<span class=\"n\">href<\/span>-<span class=\"n\">counter<\/span>\/<span class=\"n\">app<\/span> .\r\n<span class=\"n\">CMD<\/span> [<span class=\"s2\">\".\/app\"<\/span>]  \r\n\r\n<\/pre>\n<\/div>\n<\/div>\n<h2>Step #1. Setup Docker<\/h2>\n<ol style=\"list-style-type: lower-alpha;\">\n<li>From the docker site, install the latest version of the docker for your <a href=\"https:\/\/docs.docker.com\/engine\/installation\/\" target=\"_blank\" rel=\"noopener\">platform<\/a>. Docker is available in two editions: Community Edition (CE) and Enterprise Edition (EE). Docker Community Edition (CE) is ideal for developers and small teams looking to get started with Docker and experimenting with container-based apps. Docker Enterprise Edition (EE) is designed for enterprise development and IT teams who build, ship, and run business-critical applications in production at scale.<\/li>\n<li>Once the installation of docker is over, check the installation by running following command <em>docker run hello-world<\/em>:\n<p><figure id=\"attachment_1057\" aria-describedby=\"caption-attachment-1057\" style=\"width: 847px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1057\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2017\/11\/29\/docker-tutorial-build-docker-image-for-your-java-application\/dock1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?fit=847%2C223&amp;ssl=1\" data-orig-size=\"847,223\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"dock1\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Image- docker hello world&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?fit=847%2C223&amp;ssl=1\" class=\"size-full wp-image-1057 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=847%2C223\" alt=\"Docker\" width=\"847\" height=\"223\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?w=847&amp;ssl=1 847w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=300%2C79&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=768%2C202&amp;ssl=1 768w\" data-sizes=\"auto, (max-width: 847px) 100vw, 847px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 847px; --smush-placeholder-aspect-ratio: 847\/223;\" \/><figcaption id=\"caption-attachment-1057\" class=\"wp-caption-text\">Image- docker hello world<\/figcaption><\/figure><\/li>\n<li>Run <em>docker &#8211;version<\/em> to check the version of the docker you\u2019re running.\n<p><figure id=\"attachment_1058\" aria-describedby=\"caption-attachment-1058\" style=\"width: 731px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"1058\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2017\/11\/29\/docker-tutorial-build-docker-image-for-your-java-application\/dock2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock2.png?fit=731%2C68&amp;ssl=1\" data-orig-size=\"731,68\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"dock2\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Image- check docker version&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock2.png?fit=731%2C68&amp;ssl=1\" class=\"size-full wp-image-1058 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock2.png?resize=731%2C68\" alt=\"Docker\" width=\"731\" height=\"68\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock2.png?w=731&amp;ssl=1 731w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock2.png?resize=300%2C28&amp;ssl=1 300w\" data-sizes=\"auto, (max-width: 731px) 100vw, 731px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 731px; --smush-placeholder-aspect-ratio: 731\/68;\" \/><figcaption id=\"caption-attachment-1058\" class=\"wp-caption-text\">Image- check docker version<\/figcaption><\/figure><\/li>\n<\/ol>\n<p>OK, now we have got the docker setup,next step is to define the docker container.<\/p>\n<h2>Step #2. Create Multi-stage build Dockerfile for our container<\/h2>\n<figure id=\"attachment_2276\" aria-describedby=\"caption-attachment-2276\" style=\"width: 657px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2276\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/04\/11\/create-docker-images-using-multi-stage-builds\/dockerm2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm2.png?fit=657%2C109&amp;ssl=1\" data-orig-size=\"657,109\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"dockerm2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm2.png?fit=657%2C109&amp;ssl=1\" class=\"wp-image-2276 size-full lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm2.png?resize=657%2C109\" alt=\"List images using docker images command\" width=\"657\" height=\"109\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm2.png?w=657&amp;ssl=1 657w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm2.png?resize=300%2C50&amp;ssl=1 300w\" data-sizes=\"auto, (max-width: 657px) 100vw, 657px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 657px; --smush-placeholder-aspect-ratio: 657\/109;\" \/><figcaption id=\"caption-attachment-2276\" class=\"wp-caption-text\">Image &#8211; List images using docker images command<\/figcaption><\/figure>\n<p>Before we start, use <code>docker images<\/code> command to check the list of images.<\/p>\n<p>Using your favorite editor, create a Multi-Stage Dockerfile. The first stage using the Golang SDK to build a binary. The second stage copies the resulting binary into an optimised Docker Image.<\/p>\n<p><code>FROM golang:1.6-alpine<\/code><\/p>\n<p><code>RUN mkdir \/app<\/code><br \/>\n<code>ADD . \/app\/<\/code><br \/>\n<code>WORKDIR \/app<\/code><br \/>\n<code>RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .<\/code><\/p>\n<p><code># Second Stage<\/code><br \/>\n<code>FROM alpine<\/code><br \/>\n<code>EXPOSE 80<\/code><br \/>\n<code>CMD [\"\/app\"]<\/code><\/p>\n<p><code># Copy from first stage<\/code><br \/>\n<code>COPY --from=0 \/app\/main \/app<\/code><\/p>\n<h2>Step #3. Build\u00a0Docker Image<\/h2>\n<p>Now that we have completed Dockerfile, next step is to build Docker image by <em>docker build command\u00a0<\/em><\/p>\n<p>Build the image using the<code> docker build command<\/code> below.<\/p>\n<pre>docker build -f m1docker -t golang-app .\r\n\r\n<\/pre>\n<figure id=\"attachment_2277\" aria-describedby=\"caption-attachment-2277\" style=\"width: 491px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2277\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/04\/11\/create-docker-images-using-multi-stage-builds\/dockerm1\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm1.png?fit=491%2C232&amp;ssl=1\" data-orig-size=\"491,232\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"dockerm1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm1.png?fit=491%2C232&amp;ssl=1\" class=\"wp-image-2277 size-full lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm1.png?resize=491%2C232\" alt=\"Build container image using docker build command\" width=\"491\" height=\"232\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm1.png?w=491&amp;ssl=1 491w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm1.png?resize=300%2C142&amp;ssl=1 300w\" data-sizes=\"auto, (max-width: 491px) 100vw, 491px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 491px; --smush-placeholder-aspect-ratio: 491\/232;\" \/><figcaption id=\"caption-attachment-2277\" class=\"wp-caption-text\">Image &#8211; Build container image using docker build command<\/figcaption><\/figure>\n<p>The result will be two images. One untagged that was used for the first stage and the second is the target image.<\/p>\n<p><em>Congrats! Today you&#8217;ve successfully built container image using Multi stage build.<\/em><\/p>\n<figure id=\"attachment_2278\" aria-describedby=\"caption-attachment-2278\" style=\"width: 697px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2278\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/04\/11\/create-docker-images-using-multi-stage-builds\/dockerm3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm3.png?fit=697%2C139&amp;ssl=1\" data-orig-size=\"697,139\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"dockerm3\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm3.png?fit=697%2C139&amp;ssl=1\" class=\"wp-image-2278 size-full lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm3.png?resize=697%2C139\" alt=\"List the images using docker images command\" width=\"697\" height=\"139\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm3.png?w=697&amp;ssl=1 697w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/dockerm3.png?resize=300%2C60&amp;ssl=1 300w\" data-sizes=\"auto, (max-width: 697px) 100vw, 697px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 697px; --smush-placeholder-aspect-ratio: 697\/139;\" \/><figcaption id=\"caption-attachment-2278\" class=\"wp-caption-text\">Image &#8211; List the images using docker images command<\/figcaption><\/figure>\n<p>When using multi-stage builds, you are not limited to copying from stages you created earlier in your Dockerfile. You can also use the\u00a0<code class=\"highlighter-rouge\">COPY --from<\/code>\u00a0instruction to copy from a separate image, either using the local image name, a tag available locally or on a Docker registry, or a tag ID. The Docker client pulls the image if necessary and copies the artifact from there. Example below<\/p>\n<pre><code class=\"language-Dockerfile\">COPY --from=nginx:latest \/etc\/nginx\/nginx.conf \/nginx.conf\r\n\r\n<\/code><\/pre>\n<p>There is much more to the Docker platform than what was covered here, but now you would have got a good idea of the basics of building containers using multi-stage builds.<\/p>\n<p><em><strong>Like this post? Don\u2019t forget to share it!<\/strong><\/em><\/p>\n<h2>Useful Resources:<\/h2>\n<ul>\n<li><a href=\"https:\/\/docs.docker.com\/reference\/builder\/\" target=\"_blank\" rel=\"noopener\">Official documentation<\/a> as a reference to understand any command.<\/li>\n<li><a href=\"https:\/\/docs.docker.com\/articles\/dockerfile_best-practices\/\" target=\"_blank\" rel=\"noopener\">Best Practices<\/a> article on writing Docker files.<\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/01\/17\/top-6-gui-tools-for-managing-docker-environments\/\">TOP 6 GUI tools for managing Docker environments<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2017\/11\/29\/docker-tutorial-build-docker-image-for-your-java-application\/\">Docker tutorial \u2013 Build Docker image for your Java application<\/a><\/li>\n<li><a href=\"https:\/\/docs.docker.com\/\" target=\"_blank\" rel=\"noopener\">Test<\/a> your knowledge on Dockerfile.<\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/05\/23\/everything-you-need-to-know-about-docker-enterprise-3-0\/\">Everything You Need To Know About Docker Enterprise 3.0<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/10\/how-to-aggregate-docker-container-logs-and-analyse-with-elk-stack\/\">How to aggregate Docker Container logs and analyse with ELK stack ?<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/04\/implementing-secure-containers-using-gvisordocker-tutorial\/\">Implementing secure containers using gVisor+Docker tutorial<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>From the last post, we have understood what is container &amp; why do we use containers in general. Just to recap here are some of the key points Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1061,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[310,146],"tags":[53],"class_list":["post-2273","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-cloud","tag-docker"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/docker_facebook_share.png?fit=336%2C287&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9fbQS-AF","jetpack-related-posts":[{"id":415,"url":"https:\/\/www.upnxtblog.com\/index.php\/2017\/09\/07\/10-things-know-containerization-technology\/","url_meta":{"origin":2273,"position":0},"title":"10 things you should know about containerization technology","author":"Karthik","date":"September 7, 2017","format":false,"excerpt":"Linux containers have been around since the early 2000s and architected into Linux in 2007. Due to the small footprint and portability of containers, the same hardware can support an exponentially larger number of containers than VMs, dramatically reducing infrastructure costs and enabling more apps to deploy faster. But due\u2026","rel":"","context":"In &quot;Cloud Computing&quot;","block_context":{"text":"Cloud Computing","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/cloud\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/09\/container2.png?fit=638%2C343&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/09\/container2.png?fit=638%2C343&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/09\/container2.png?fit=638%2C343&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1748,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/01\/17\/top-6-gui-tools-for-managing-docker-environments\/","url_meta":{"origin":2273,"position":1},"title":"TOP 6 GUI tools for managing Docker environments","author":"Karthik","date":"January 17, 2018","format":false,"excerpt":"Before we start, a little bit of intro on Containers, its an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in userspace. Containers take up less\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/01\/dashboard.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/01\/dashboard.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/01\/dashboard.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/01\/dashboard.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/01\/dashboard.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":3179,"url":"https:\/\/www.upnxtblog.com\/index.php\/2019\/01\/04\/implementing-secure-containers-using-gvisordocker-tutorial\/","url_meta":{"origin":2273,"position":2},"title":"Implementing secure containers using gVisor+Docker tutorial","author":"Karthik","date":"January 4, 2019","format":false,"excerpt":"Linux containers have been around since the early 2000s and architected into Linux in 2007. Due to the small footprint and portability of containers, the same hardware can support an exponentially larger number of containers than VMs, dramatically reducing infrastructure costs and enabling more apps to deploy faster. But due\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/10\/google_chrome-logo.png?fit=800%2C473&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":2949,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/09\/26\/how-to-run-multiple-services-in-a-docker-container\/","url_meta":{"origin":2273,"position":3},"title":"How to run multiple services in a Docker container","author":"Karthik","date":"September 26, 2018","format":false,"excerpt":"Docker as we know,is an open platform for developers and sysadmins to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud. Before we move on to the actual article, some key points about containers : Containers are an abstraction at the app layer that\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"Validate Docker Installation","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock14.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock14.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock14.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/09\/dock14.png?resize=700%2C400 2x"},"classes":[]},{"id":2336,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/04\/20\/docker-tutorial-swarm-mode\/","url_meta":{"origin":2273,"position":4},"title":"Docker tutorial &#8211; Create,Add Nodes,Deploy and Scale service on the Swarm","author":"Karthik","date":"April 20, 2018","format":false,"excerpt":"From the last post, we have understood what is container & why do we use containers in general. Just to recap here are some of the key points Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"Docker","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/dock1.png?resize=700%2C400 2x"},"classes":[]},{"id":4971,"url":"https:\/\/www.upnxtblog.com\/index.php\/2020\/04\/22\/do-you-inspect-your-containers\/","url_meta":{"origin":2273,"position":5},"title":"Do you inspect your containers?","author":"Karthik","date":"April 22, 2020","format":false,"excerpt":"With the increasing adoption of containers and microservices in the enterprises, there are also risks that come along with containers. For example, If any one of the containers breaks out, it can allow unauthorized access across containers, hosts, or data centers, etc., thus affecting all the containers hosted on the\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2020\/04\/ami3.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2020\/04\/ami3.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2020\/04\/ami3.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2020\/04\/ami3.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=2273"}],"version-history":[{"count":10,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2273\/revisions"}],"predecessor-version":[{"id":5395,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/2273\/revisions\/5395"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/media\/1061"}],"wp:attachment":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=2273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=2273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=2273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}