{"id":2759,"date":"2023-05-22T20:58:35","date_gmt":"2023-05-22T19:58:35","guid":{"rendered":"https:\/\/hypervlab.co.uk\/?p=2759"},"modified":"2023-05-22T20:58:36","modified_gmt":"2023-05-22T19:58:36","slug":"building-your-first-docker-image","status":"publish","type":"post","link":"https:\/\/hypervlab.co.uk\/?p=2759","title":{"rendered":"Building your first docker image"},"content":{"rendered":"<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>\n<p>Hello, In this blog post, we will cover the basics of creating a docker image from a docker file. So for those who are new to Docker, I would first advise you have a read of this: <a href=\"https:\/\/docs.docker.com\/get-started\/\" target=\"_blank\" rel=\"noreferrer noopener\">Getting Started<\/a> with Docker. Now that you&#8217;re acquainted with what the Docker platform is next, you&#8217;ll want to check this <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\" target=\"_blank\" rel=\"noreferrer noopener\">Dockerfile Reference<\/a> on the ins and out of what a Docker File is. <\/p>\n\n\n\n<p>The TLDR Overview of a DockerFile is that it&#8217;s a configuration file which allows you to build a container image from an Operating System and install any required packages or scripts required for the image\/solution to run. <\/p>\n\n\n\n<p>Before we can start building docker images, we first need to install Docker Desktop, You can download the DockerDesktop setup file from well docker&#8217;s website. <a href=\"https:\/\/www.docker.com\/products\/docker-desktop\/\" target=\"_blank\" rel=\"noreferrer noopener\">Download Here<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"429\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-1024x429.png\" alt=\"\" class=\"wp-image-2762\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-1024x429.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-300x126.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-768x322.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-1536x643.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-1003x420.png 1003w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-640x268.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5-681x285.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-5.png 2011w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-1024x709.png\" alt=\"\" class=\"wp-image-2763\" width=\"768\" height=\"532\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-1024x709.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-300x208.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-768x532.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-607x420.png 607w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-640x443.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6-681x471.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-6.png 1062w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>NOTE: Please note you will be required to reboot your device after Docker Desktop has been installed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating a Basic Dockerfile<\/h3>\n\n\n\n<p>The first requirement of a Dockerfil file is the FROM instruction, This outlines which operating system the image will be built from, Now this can be either Windows or Linux. the FROM Instruction can be defined in a couple of ways.<\/p>\n\n\n\n<p>Option One:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM &#91;--platform=&lt;platform&gt;] &lt;image&gt; &#91;AS &lt;name&gt;]<\/code><\/pre>\n\n\n\n<p>Option Two:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM &#91;--platform=&lt;platform&gt;] &lt;image&gt;&#91;:&lt;tag&gt;] &#91;AS &lt;name&gt;]<\/code><\/pre>\n\n\n\n<p>Option Three:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM &#91;--platform=&lt;platform&gt;] &lt;image&gt;&#91;@&lt;digest&gt;] &#91;AS &lt;name&gt;]<\/code><\/pre>\n\n\n\n<p>FROM INSTRUCTION ARGS TABLE: (borrowed from the docker website)<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ARG<\/code>&nbsp;is the only instruction that may precede&nbsp;<code>FROM<\/code>&nbsp;in the&nbsp;<code>Dockerfile<\/code>. See&nbsp;<a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#understand-how-arg-and-from-interact\">Understand how ARG and FROM interact<\/a>.<\/li>\n\n\n\n<li><code>FROM<\/code>&nbsp;can appear multiple times within a single&nbsp;<code>Dockerfile<\/code>&nbsp;to create multiple images or use one build stage as a dependency for another. Simply make a note of the last image ID output by the commit before each new&nbsp;<code>FROM<\/code>&nbsp;instruction. Each&nbsp;<code>FROM<\/code>&nbsp;instruction clears any state created by previous instructions.<\/li>\n\n\n\n<li>Optionally a name can be given to a new build stage by adding&nbsp;<code>AS name<\/code>&nbsp;to the&nbsp;<code>FROM<\/code>&nbsp;instruction. The name can be used in subsequent&nbsp;<code>FROM<\/code>&nbsp;and&nbsp;<code>COPY --from=&lt;name&gt;<\/code>&nbsp;instructions to refer to the image built in this stage.<\/li>\n\n\n\n<li>The&nbsp;<code>tag<\/code>&nbsp;or&nbsp;<code>digest<\/code>&nbsp;values are optional. If you omit either of them, the builder assumes a&nbsp;<code>latest<\/code>&nbsp;tag by default. The builder returns an error if it cannot find the&nbsp;<code>tag<\/code>&nbsp;value.<\/li>\n<\/ul>\n\n\n\n<p><br> For this example, we are going to create a Dockerfile file using <a href=\"https:\/\/www.alpinelinux.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Alpine Linux<\/a>.<br> From the example below the Operating System is: alpine and the version release we are using is 3.14<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM alpine:3.14<\/code><\/pre>\n\n\n\n<p>You can get the current versions from the <a href=\"https:\/\/hub.docker.com\/_\/alpine\" target=\"_blank\" rel=\"noreferrer noopener\">DockerHub Repository for Alpine Linux<\/a><br>So now we can create the Dockerfile, For this blog post, we will be creating files under C:\\Code\\hypervlab-blog.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>New-Item -ItemType \"Directory\" -Path \"C:\\Code\\hypervlab-blog\"<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-1024x569.png\" alt=\"\" class=\"wp-image-2768\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-10.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>Next, we want to create the Dockerfile file, Which will be used to create our Docker image<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>New-Item -ItemType \"File\" -Path \"C:\\Code\\hypervlab-blog\\Dockerfile\"<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-1024x569.png\" alt=\"\" class=\"wp-image-2769\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-11.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>Now we have a blank Dockerfile, we can open the file, for this example, I&#8217;m using VSCode.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM alpine:3.14<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-1024x682.png\" alt=\"\" class=\"wp-image-2775\" width=\"768\" height=\"512\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-1024x682.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-300x200.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-768x511.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-1536x1023.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-2048x1363.png 2048w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-631x420.png 631w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-640x426.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-17-681x453.png 681w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>This is a very vanilla Dockerfile, At this stage, all this will do when we build is download the Operating System (alpine 3.14) and create an image for us to reuse at a later date.  So once the FROM value has been added and saved to the Dockerfile we need to CD into the working directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Set-Location -Path C:\\Code\\hypervlab-blog<\/code><\/pre>\n\n\n\n<p>So now we can create our first docker image using the following command below. <br>NOTE: using the &#8220;.&#8221; tells docker that the Dockerfile is located in the same folder, You can also pass the -f flag if the Dockerfile is within another folder or directory. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker build -t myalpineimage . <\/code><\/pre>\n\n\n\n<p>using the following command you will see the build output shown below. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-1024x569.png\" alt=\"\" class=\"wp-image-2776\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-18.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>However, this is where I shall highlight the importance of versioning or &#8220;tagging&#8221; if you run the above command, Which we&#8217;ve just completed when you check the docker images now stored on your local device you will see the following:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker image list <\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-1024x569.png\" alt=\"\" class=\"wp-image-2777\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-19.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>Notice how the image version shows as &#8220;latest&#8221; This doesn&#8217;t really tell us anything useful and there is no visible version controlling numbers. <br>So should you have a problem with the build at any point, which version of the build was broken? So I would advise when building images to use a tag &#8211; for example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker build -t myalpineimage:0.1 .<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-1024x569.png\" alt=\"\" class=\"wp-image-2778\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-20.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>Now when we check the current images in the docker library we can now see that the tag shows as version 0.1. So we will know when it broke. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker image list <\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-1024x569.png\" alt=\"\" class=\"wp-image-2779\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-21.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Creating a Function Docker File<\/h2>\n\n\n\n<p>So in the previous steps, we&#8217;ve covered the very very basics of creating an image, granted there is nothing in that image apart from just Alpine Linux. So using the below Dockerfile we will create a container image which contains PowerShell 7.3.4 (at the time of the blog post the latest release).<br>There is a super useful Microsoft Learn article on installing Powershell into Alpine Linx [<a href=\"https:\/\/learn.microsoft.com\/en-us\/powershell\/scripting\/install\/install-alpine?view=powershell-7.3\" target=\"_blank\" rel=\"noreferrer noopener\">Link Here<\/a>]<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Define Operating System for Image\r\nFROM alpine:3.14\r\n\r\n# Execute Package Update and Upgrade\r\nRUN apk update\r\nRUN apk add --no-cache ca-certificates less ncurses-terminfo-base krb5-libs libgcc libintl libssl1.1 libstdc++ tzdata userspace-rcu zlib icu-libs curl\r\nRUN apk -X https:\/\/dl-cdn.alpinelinux.org\/alpine\/edge\/main add --no-cache lttng-ust\r\n\r\n# Download the powershell '.tar.gz' archive\r\nRUN curl -L https:\/\/github.com\/PowerShell\/PowerShell\/releases\/download\/v7.3.4\/powershell-7.3.4-linux-alpine-x64.tar.gz -o \/tmp\/powershell.tar.gz\r\n\r\n# Create the target folder where powershell will be placed\r\nRUN mkdir -p \/opt\/microsoft\/powershell\/7\r\n\r\n# Expand powershell to the target folder\r\nRUN tar zxf \/tmp\/powershell.tar.gz -C \/opt\/microsoft\/powershell\/7\r\n\r\n# Set execute permissions and create the symbolic link that points to pwsh\r\nRUN chmod +x \/opt\/microsoft\/powershell\/7\/pwsh\r\nRUN ln -s \/opt\/microsoft\/powershell\/7\/pwsh \/usr\/bin\/pwsh\r\n\r\n# Start PowerShell\r\nENTRYPOINT pwsh<\/code><\/pre>\n\n\n\n<p>Build Time!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> docker build -t myalpineimage:0.2 .<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-1024x569.png\" alt=\"\" class=\"wp-image-2781\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-22.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>Now when we check the docker images, we can see that the myalpineimage 0.2 is now 320MB as it now holds the PowerShell Modules.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker image list <\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-1024x569.png\" alt=\"\" class=\"wp-image-2782\" width=\"768\" height=\"427\" srcset=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-1024x569.png 1024w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-300x167.png 300w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-768x427.png 768w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-1536x854.png 1536w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-756x420.png 756w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-640x356.png 640w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23-681x378.png 681w, https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/image-23.png 1614w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure><\/div>\n\n\n<p>So to wrap up this post, We have covered the steps for creating the world&#8217;s most basic alpine linux image and a more functional image which contains PowerShell. In the next blog post, we will look into how to take this image we&#8217;ve just created and run the container locally. <br><br>Otherwise, I&#8217;ll catch you over on Twitter at <a href=\"https:\/\/twitter.com\/smoon_lee\" target=\"_blank\" rel=\"noreferrer noopener\">@smoon_lee<\/a><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Reading Time: <\/span> <span class=\"rt-time\"> 5<\/span> <span class=\"rt-label rt-postfix\">minutes<\/span><\/span>Hello, In this blog post, we will cover the basics of creating a docker image from a docker file. So for those who are new to Docker, I would first advise you have a read of this: Getting Started with Docker. Now that you&#8217;re acquainted with what the Docker platform is next, you&#8217;ll want to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2761,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[337,339,338,336,121],"class_list":{"0":"post-2759","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-docker","8":"tag-alpine","9":"tag-clouds","11":"tag-docker","12":"tag-linux"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Building your first docker image - HypervLAB<\/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:\/\/hypervlab.co.uk\/?p=2759\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Building your first docker image - HypervLAB\" \/>\n<meta property=\"og:description\" content=\"Reading Time:  5 minutesHello, In this blog post, we will cover the basics of creating a docker image from a docker file. So for those who are new to Docker, I would first advise you have a read of this: Getting Started with Docker. Now that you&#8217;re acquainted with what the Docker platform is next, you&#8217;ll want to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hypervlab.co.uk\/?p=2759\" \/>\n<meta property=\"og:site_name\" content=\"HypervLAB\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-22T19:58:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-22T19:58:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Simon Lee\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/smoon_lee\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Simon Lee\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/hypervlab.co.uk\/?p=2759\",\"url\":\"https:\/\/hypervlab.co.uk\/?p=2759\",\"name\":\"Building your first docker image - HypervLAB\",\"isPartOf\":{\"@id\":\"https:\/\/hypervlab.co.uk\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/hypervlab.co.uk\/?p=2759#primaryimage\"},\"image\":{\"@id\":\"https:\/\/hypervlab.co.uk\/?p=2759#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png\",\"datePublished\":\"2023-05-22T19:58:35+00:00\",\"dateModified\":\"2023-05-22T19:58:36+00:00\",\"author\":{\"@id\":\"https:\/\/hypervlab.co.uk\/#\/schema\/person\/7d184970612a9c6a5f1babb8b6b4d359\"},\"breadcrumb\":{\"@id\":\"https:\/\/hypervlab.co.uk\/?p=2759#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/hypervlab.co.uk\/?p=2759\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/hypervlab.co.uk\/?p=2759#primaryimage\",\"url\":\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png\",\"contentUrl\":\"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png\",\"width\":1200,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/hypervlab.co.uk\/?p=2759#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/hypervlab.co.uk\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Building your first docker image\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/hypervlab.co.uk\/#website\",\"url\":\"https:\/\/hypervlab.co.uk\/\",\"name\":\"HypervLAB\",\"description\":\"Blogging about all thing Microsoft\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/hypervlab.co.uk\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/hypervlab.co.uk\/#\/schema\/person\/7d184970612a9c6a5f1babb8b6b4d359\",\"name\":\"Simon Lee\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\/\/hypervlab.co.uk\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9473a3cf9c75192508eccfd9d072efab80adf04a45083e561d0e3065f681c34c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9473a3cf9c75192508eccfd9d072efab80adf04a45083e561d0e3065f681c34c?s=96&d=mm&r=g\",\"caption\":\"Simon Lee\"},\"description\":\"Hi, I'm Simon an IT Enthusiast, PowerShell Geek, Gamer, and Sound Engineer. I've been working with in the IT Industry for around 6 years and have worked across private and public sector companies. The original idea behind \\\"hypervlab\\\" was that I required an 'RnD' environment which would allow me to be able to replicate any kind of enterprise on-premise environment which I could use for learning and testing without learning in a production environment. So in 2019, I decided to branch out and use the domain for a public facing blog to be able to contribute to the IT Community about all things Microsoft.\",\"sameAs\":[\"https:\/\/hypervlab.co.uk\",\"https:\/\/www.linkedin.com\/in\/simon-john-lee\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/smoon_lee\"],\"url\":\"https:\/\/hypervlab.co.uk\/?author=2\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Building your first docker image - HypervLAB","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:\/\/hypervlab.co.uk\/?p=2759","og_locale":"en_GB","og_type":"article","og_title":"Building your first docker image - HypervLAB","og_description":"Reading Time:  5 minutesHello, In this blog post, we will cover the basics of creating a docker image from a docker file. So for those who are new to Docker, I would first advise you have a read of this: Getting Started with Docker. Now that you&#8217;re acquainted with what the Docker platform is next, you&#8217;ll want to [&hellip;]","og_url":"https:\/\/hypervlab.co.uk\/?p=2759","og_site_name":"HypervLAB","article_published_time":"2023-05-22T19:58:35+00:00","article_modified_time":"2023-05-22T19:58:36+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png","type":"image\/png"}],"author":"Simon Lee","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/smoon_lee","twitter_misc":{"Written by":"Simon Lee","Estimated reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/hypervlab.co.uk\/?p=2759","url":"https:\/\/hypervlab.co.uk\/?p=2759","name":"Building your first docker image - HypervLAB","isPartOf":{"@id":"https:\/\/hypervlab.co.uk\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hypervlab.co.uk\/?p=2759#primaryimage"},"image":{"@id":"https:\/\/hypervlab.co.uk\/?p=2759#primaryimage"},"thumbnailUrl":"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png","datePublished":"2023-05-22T19:58:35+00:00","dateModified":"2023-05-22T19:58:36+00:00","author":{"@id":"https:\/\/hypervlab.co.uk\/#\/schema\/person\/7d184970612a9c6a5f1babb8b6b4d359"},"breadcrumb":{"@id":"https:\/\/hypervlab.co.uk\/?p=2759#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hypervlab.co.uk\/?p=2759"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/hypervlab.co.uk\/?p=2759#primaryimage","url":"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png","contentUrl":"https:\/\/hypervlab.co.uk\/wp-content\/uploads\/2023\/05\/header_building_your_first_docker_image.png","width":1200,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/hypervlab.co.uk\/?p=2759#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hypervlab.co.uk\/"},{"@type":"ListItem","position":2,"name":"Building your first docker image"}]},{"@type":"WebSite","@id":"https:\/\/hypervlab.co.uk\/#website","url":"https:\/\/hypervlab.co.uk\/","name":"HypervLAB","description":"Blogging about all thing Microsoft","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hypervlab.co.uk\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/hypervlab.co.uk\/#\/schema\/person\/7d184970612a9c6a5f1babb8b6b4d359","name":"Simon Lee","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/hypervlab.co.uk\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9473a3cf9c75192508eccfd9d072efab80adf04a45083e561d0e3065f681c34c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9473a3cf9c75192508eccfd9d072efab80adf04a45083e561d0e3065f681c34c?s=96&d=mm&r=g","caption":"Simon Lee"},"description":"Hi, I'm Simon an IT Enthusiast, PowerShell Geek, Gamer, and Sound Engineer. I've been working with in the IT Industry for around 6 years and have worked across private and public sector companies. The original idea behind \"hypervlab\" was that I required an 'RnD' environment which would allow me to be able to replicate any kind of enterprise on-premise environment which I could use for learning and testing without learning in a production environment. So in 2019, I decided to branch out and use the domain for a public facing blog to be able to contribute to the IT Community about all things Microsoft.","sameAs":["https:\/\/hypervlab.co.uk","https:\/\/www.linkedin.com\/in\/simon-john-lee\/","https:\/\/x.com\/https:\/\/twitter.com\/smoon_lee"],"url":"https:\/\/hypervlab.co.uk\/?author=2"}]}},"_links":{"self":[{"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2759"}],"version-history":[{"count":7,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2759\/revisions"}],"predecessor-version":[{"id":2787,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/2759\/revisions\/2787"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=\/wp\/v2\/media\/2761"}],"wp:attachment":[{"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hypervlab.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}