{"id":70200,"date":"2017-03-07T16:36:17","date_gmt":"2017-03-07T16:36:17","guid":{"rendered":"https:\/\/www.simple-talk.com\/?p=70200"},"modified":"2021-04-27T13:55:26","modified_gmt":"2021-04-27T13:55:26","slug":"working-windows-containers-docker-running","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/devops\/containers-and-virtualization\/working-windows-containers-docker-running\/","title":{"rendered":"Working with Windows Containers and Docker: Up and Running"},"content":{"rendered":"<ul>\n<li><a href=\"https:\/\/www.simple-talk.com\/sysadmin\/virtualization\/working-windows-containers-docker-basics\/\">First Part \u2013 The basics<\/a>: the basic principles of how container virtualization is implemented in Windows Server 2016 operating system.<\/li>\n<li><a href=\"https:\/\/www.simple-talk.com\/sysadmin\/virtualization\/working-windows-containers-docker-running\/\">Second part \u2013 Up and Running<\/a>: creating and managing Windows Server Containers using Docker.<\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sysadmin\/virtualization\/working-windows-containers-docker-stride\/\">Third part \u2013 Into your Stride<\/a> Working with Windows Containers and Docker<\/li>\n<li><a href=\"https:\/\/www.red-gate.com\/simple-talk\/sysadmin\/containerization\/working-windows-containers-docker-save-data\/\">Fourth part<\/a> -- Save the Container Data<\/li>\n<\/ul>\n\n<h2>Overview<\/h2>\n<p>In the previous article in this series, <a href=\"https:\/\/www.simple-talk.com\/sysadmin\/virtualization\/working-windows-containers-docker-basics\/\"><strong>Working with Windows Containers and Docker: The Basics<\/strong><\/a><strong>, <\/strong>I examined the basics of how container virtualization is being implemented in the Windows Server 2016 operating system. With this basic run-through of Windows Containers out of the way, I can go on to explain how you can work with this new feature in Windows Server 2016.<\/p>\n<h2>Introduction<\/h2>\n<p>In <a href=\"https:\/\/www.simple-talk.com\/sysadmin\/virtualization\/working-windows-containers-docker-basics\/\">Part 1<\/a> of this series, we learned about Windows Containers Fundamentals and Docker. Containers provide lightweight and Agile virtualization capabilities that developers can use to quickly deploy and update apps in their own development environment. This article will explain how to create and manage Windows Server Containers using Docker. By the end of this step, we will have our Container Host up and running with just one IIS container. That\u2019s pretty cool!<\/p>\n<h2>Windows Server 2016 with Containers on Azure<\/h2>\n<p>For many Developers and Sysadmins, it makes a lot of sense to deploy services to the Microsoft Azure cloud, but you have the additional option of deploying your Container Host to the Microsoft Azure cloud. One of the advantages of using Azure in this way is that you can deploy a Windows Server 2016 virtual machine with the Containers feature already installed. By doing so, you are then able to experiment with Windows Server Container, with both Server Core and Nano Server Container OS Images installed and ready to use with Docker.<\/p>\n<p>Log in to your Azure portal and create a virtual machine using the Windows Server 2016 Core with Containers image, as shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1512\" height=\"678\" class=\"wp-image-70201\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-1.png\" \/><\/p>\n<h2>Docker Commands<\/h2>\n<p>How do you set about working with Docker on Windows Server? Before going more into the practical side, we need to get familiar with the essential Docker PowerShell commands. You can run the <strong><em>docker \u2013help<\/em><\/strong> command:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">Commands:\r\n    attach      Attach to a running container\r\n    build       Build an image from a Dockerfile\r\n    commit      Create a new image from a container's changes\r\n    cp          Copy files\/folders between a container and the local filesystem\r\n    create      Create a new container\r\n    diff        Inspect changes on a container's filesystem\r\n    events      Get real time events from the server\r\n    exec        Run a command in a running container\r\n    export      Export a container's filesystem as a tar archive\r\n    history     Show the history of an image\r\n    images      List images\r\n    import      Import the contents from a tarball to create a filesystem image\r\n    info        Display system-wide information\r\n    inspect     Return low-level information on a container, image or task\r\n    kill        Kill one or more running containers\r\n    load        Load an image from a tar archive or STDIN\r\n    login       Log in to a Docker registry.\r\n    logout      Log out from a Docker registry.\r\n    logs        Fetch the logs of a container\r\n    pause       Pause all processes within one or more containers\r\n    port        List port mappings or a specific mapping for the container\r\n    ps          List containers\r\n    pull        Pull an image or a repository from a registry\r\n    push        Push an image or a repository to a registry\r\n    rename      Rename a container\r\n    restart     Restart one or more containers\r\n    rm          Remove one or more containers\r\n    rmi         Remove one or more images\r\n    run         Run a command in a new container\r\n    save        Save one or more images to a tar archive (streamed to STDOUT by default)\r\n    search      Search the Docker Hub for images\r\n    start       Start one or more stopped containers\r\n    stats       Display a live stream of container(s) resource usage statistics\r\n    stop        Stop one or more running containers\r\n    tag         Tag an image into a repository\r\n    top         Display the running processes of a container\r\n    unpause     Unpause all processes within one or more containers\r\n    update      Update configuration of one or more containers\r\n    version     Show the Docker version information\r\n    wait        Block until one or more containers stop, then print their exit codes\r\n  Run 'docker COMMAND --help' for more information on a command.<\/pre>\n<p>There is enough here for everyday use. We\u2019ll get started by using one of the most common of the Docker commands:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker images<\/pre>\n<p>This command shows you which Docker Images are available locally. After installing Windows Containers no Docker Images are, as yet, installed. The first thing you have to do is to pull Windows Server Images from the Docker Hub. You don\u2019t need a Docker Hub Account to perform this task:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker pull &lt;image_name&gt;<\/pre>\n<p>I will describe this command in more detail in the next section. When you have at least one image available, you can start a Windows Container:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker run -\u2013name &lt;Container_Name&gt; &lt;Image_Name&gt;<\/pre>\n<p>It means that a Windows Container called <strong>&lt;Container_Name&gt;<\/strong> will be started from the Image called <strong>&lt;Image_Name&gt;.<\/strong> When you have more than one container running, it can be useful to get a list of all running containers:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker ps<\/pre>\n<p>Finally, you will need some information about your containers, such as the IP Address. Use the following to retrieve this information:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker inspect<\/pre>\n<h2>Retrieve Images from Docker Hub<\/h2>\n<p>In Docker container parlance, the image is the template from which you spawn new containers. We can download some pre-built Docker images from the Docker Hub. At the time this was written, Microsoft has two container images in their gallery: Nano Server and Windows Server Core. Let&#8217;s download them both by pulling the images from Docker Hub:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker images\r\n  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE\r\n  PS &gt; docker pull microsoft\/windowsservercore\r\n  Using default tag: latest\r\n  latest: Pulling from microsoft\/windowsservercore\r\n  3889bb8d808b: Downloading [=&gt;                                                 ] 102.7 MB\/4.07 GB\r\n  3430754e4d17: Downloading [=====&gt;                                             ] 102.2 MB\/913.1 MB\r\n  PS &gt; docker pull microsoft\/nanoserver\r\n  [\u2026]<\/pre>\n<p>Ok, but how to know the exact name of the image that you need? That\u2019s pretty simple. On Docker Hub, you will notice the following section named \u201cDocker Pull Command\u201d as shown below.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1037\" height=\"702\" class=\"wp-image-70202\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-2.png\" \/><\/p>\n<p>The only necessary step is to copy and paste the command to download the image. Once the image installation process completes (it can take a while, depending on your Internet connection speed), confirm that Windows Server Core image is available locally. Run <strong>Docker images<\/strong> to check:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker images\r\n  REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE\r\n  microsoft\/windowsservercore   latest              4d83c32ad497        6 weeks ago         9.56GB\r\n  microsoft\/nanoserver          latest              d9bccb9d4cac        6 weeks ago         925MB<\/pre>\n<p>If you have deployed the pre-configured virtual machine in Azure, the two base images are already pulled.<\/p>\n<h2>Deploy a new Windows Container<\/h2>\n<p>Now we will use the\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/run\/\"><strong>Docker<\/strong><\/a><strong> run<\/strong> command\u00a0to deploy a new container named\u00a0<strong>CoreServerCMD<\/strong>\u00a0that uses the Windows Server Core image. The <strong>-it<\/strong> switch denotes an interactive session, and\u00a0<strong>cmd.exe<\/strong>\u00a0means that we want to enter the container inside a new cmd.exe console. Be careful, the repository name must be lowercase.<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker run -it --name CoreServerCMD microsoft\/windowsservercore cmd.exe\r\n  Microsoft Windows [Version 10.0.14393]\r\n  (c) 2016 Microsoft Corporation. All rights reserved.\r\n  C:\\&gt;ipconfig\r\n  Windows IP Configuration\r\n  Ethernet adapter vEthernet (Container NIC b4dc9191):\r\n     Connection-specific DNS Suffix  . :\r\n     Link-local IPv6 Address . . . . . : fe80::81ac:61de:7cef:3467%17\r\n     IPv4 Address. . . . . . . . . . . : 172.21.149.87\r\n     Subnet Mask . . . . . . . . . . . : 255.255.240.0\r\n     Default Gateway . . . . . . . . . : 172.21.144.1<\/pre>\n<p>Basically, the\u00a0<strong>docker run<\/strong>\u00a0translates the\u00a0<strong>cmd.exe<\/strong>\u00a0command within the new Server Core-based container. Now, we have a container named <strong>CoreServerCMD<\/strong> which is running. We can check with the <strong>Docker ps<\/strong> command:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker ps\r\n  CONTAINER ID  IMAGE                        COMMAND  CREATED       STATUS       NAMES\r\n  9e8e23686548  microsoft\/windowsservercore \"cmd.exe\" 5 minutes ago Up 3 minutes CoreServerCMD<\/pre>\n<p>The <strong>Docker ps<\/strong> command by default shows only running containers but passing the <strong>-a<\/strong> flag to the command will show all containers. You can start and stop containers very simply by running:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; <a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/stop\/\">docker stop<\/a> CoreServerCMD\r\n  CoreServerCMD\r\n  PS &gt; <a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/stop\/\">docker st<\/a>art CoreServerCMD\r\n  CoreServerCMD<\/pre>\n<p>When you start a Windows Container, take a look at the Task Manager tool and you will notice a new process called \u201cDocker\u201d. When you stop your container, this process will disappear:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"371\" class=\"wp-image-70203\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-3.png\" \/><\/p>\n<p>OK, the container is up and running but you don\u2019t need to execute the <strong>docker run<\/strong> command once again. To re-enter the running container, the <strong>docker attach<\/strong> command will do the job:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; <a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/attach\/\">docker attach<\/a>\u00a0CoreServerCMD<\/pre>\n<p>Containers have both a name and identifier, and either of them can be used to identify the container to inspect. <strong>Inspect<\/strong> is a core Docker instruction (<a href=\"https:\/\/docs.docker.com\/engine\/reference\/commandline\/inspect\/\">Docker Docs- Docker Inspect<\/a>) that allows you to get all the information about Container and Image. Below, I inspect my container:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker inspect CoreServerCMD\r\n  [\r\n      {\r\n          \"Id\": \"9e8e236865487f3f715d2b1d5582512d9f068f97219c01249a497e03afcff94d\",\r\n          \"Created\": \"2017-02-26T12:20:41.2866341Z\",\r\n          \"Path\": \"cmd.exe\",\r\n          \"Args\": [],\r\n          \"State\": {\r\n              \"Status\": \"exited\",\r\n              \"Running\": false,\r\n              \"Paused\": false,\r\n              \"Restarting\": false,\r\n              \"OOMKilled\": false,\r\n              \"Dead\": false,\r\n              \"Pid\": 0,\r\n              \"ExitCode\": 9009,\r\n              \"Error\": \"\",\r\n              \"StartedAt\": \"2017-02-26T12:24:24.8655415Z\",\r\n              \"FinishedAt\": \"2017-02-26T12:32:26.5074121Z\"\r\n          },\r\n          \"Image\": \"sha256:4d83c32ad497f063ae77377afb9285ed3f8a2d2dc52eb53268a7152777b25add\",\r\n          \"ResolvConfPath\": \"\",\r\n          \"HostnamePath\": \"\",\r\n          \"HostsPath\": \"\",\r\n          \"LogPath\": \"C:\\\\ProgramData\\\\docker\\\\containers\\\\9e8e236865487f3f715d2b1d5582512d9f068f97219c01249a497e03afcff94d\\\\9e8e236865487f3f715d2b1d5582512d9f068f97219c01249a497e03afcff94d-json.log\",\r\n          \"Name\": \"\/CoreServerCMD\",\r\n          \"RestartCount\": 0,\r\n          \"Driver\": \"windowsfilter\",\r\n          \"MountLabel\": \"\",\r\n          \"ProcessLabel\": \"\",\r\n          \"AppArmorProfile\": \"\",\r\n          \"ExecIDs\": null,\r\n          \"HostConfig\": {\r\n              \"Binds\": null,\r\n              \"ContainerIDFile\": \"\",\r\n              \"LogConfig\": {\r\n                  \"Type\": \"json-file\",\r\n                  \"Config\": {}\r\n              },\r\n              \"NetworkMode\": \"default\",\r\n              \"PortBindings\": {},\r\n              \"RestartPolicy\": {\r\n                  \"Name\": \"no\",\r\n                  \"MaximumRetryCount\": 0\r\n  [\u2026]<\/pre>\n<p>The output has been truncated. You can display specific settings using the <strong>\u2013f<\/strong> parameter:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker inspect -f '{{.Config.Hostname}}'  CoreServerCMD\r\n  9e8e23686548\r\n  PS &gt; docker inspect -f '{{.Config.Image}}'  CoreServerCMD\r\n  microsoft\/windowsservercore\r\n  PS &gt; docker inspect -f '{{.NetworkSettings.IPAddress}}'  CoreServerCMD\r\n  172.21.149.87<\/pre>\n<h2>Build your own container image<\/h2>\n<p>Docker containers are created by using base images. Basically, an image can contain nothing more than the operating-system fundamentals, or it can contain a full application stack ready for use. So, let\u2019s see an example. You may have a custom website that you want to deploy in a Windows Container. You have two ways to do the job. You can run a Windows Container or just use a Docker file. To run a Windows Container, install and configure the IIS role and finally import your html files: To use a Docker File takes a bit more explaining. Just imagine, for the sake of this example, that you have a folder called \u201cMyWebSite\u201d containing two files:<\/p>\n<ul>\n<li>Index.html<\/li>\n<li>Dockerfile<\/li>\n<\/ul>\n<p><strong>What is a Dockerfile?<\/strong><\/p>\n<p>Dockerfile is a script, composed of various \u201ccommands\u201d also called \u201cinstructions\u201d and arguments listed successively to automatically perform actions on a base image in order to create a new one. The Dockerfile greatly helps with deployments by automating and simplifying this process.<\/p>\n<p>Below is the content of my Dockerfile:<\/p>\n<pre class=\"theme:powershell-ise lang:ps decode:true\">FROM microsoft\/iis\r\n\tMAINTAINER Nicolas PRIGENT\r\n\tRUN mkdir C:\\site\r\n\tRUN powershell -NoProfile -Command \\\r\n\t    Import-module IISAdministration; \\\r\n\t    New-IISSite -Name \"Site\" -PhysicalPath C:\\site -BindingInformation \"*:8080:\"\r\n\tCOPY index.html C:\\site\r\n\tEXPOSE 8080\r\n<\/pre>\n<p>My Dockerfile begins with a \u201cFROM\u201d keyword. This keyword defines an image from which the build process starts. In my example, I will use the Microsoft IIS image, then create a folder and finally run some PowerShell commands via the \u201cRUN\u201d keyword. Thanks to this Dockerfile, Docker will create a new container image. A\u00a0container image\u00a0is the captured state information of a container that you have created and customized on a container host. Once you have customized a container image for a particular purpose, you can then use it to create new containers from it. It\u2019s something like a \u201cTemplate\u201d for creating new containers for some specific purpose that you can list with the <strong>Docker images <\/strong>command.<\/p>\n<p><strong>Creating a container image<\/strong><\/p>\n<p>OK, my Dockerfile is ready. Here are the commands I need to run to create my new image:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; cd C:\\MyWebsite\r\n  PS C:\\MyWebsite&gt; docker build -t myiis .\r\n  Sending build context to Docker daemon  3.072kB\r\n  Step 1\/6 : FROM microsoft\/iis\r\n   ---&gt; a3dd2dff392b\r\n  Step 2\/6 : MAINTAINER Nicolas PRIGENT\r\n   ---&gt; Running in 2325e0d1cad2\r\n   ---&gt; 5c647612617c\r\n  Removing intermediate container 2325e0d1cad2\r\n  Step 3\/6 : RUN mkdir C:\\site\r\n   ---&gt; Running in bec661fdb10c\r\n   ---&gt; 5173bcee6d03\r\n  Removing intermediate container bec661fdb10c\r\n  Step 4\/6 : RUN powershell -NoProfile -Command     Import-module IISAdministration;     New-IISSite -Name \"Site\" -PhysicalPath C:\\site -BindingInformation \"*:8080:\"\r\n   ---&gt; Running in d9abe719e201\r\n   ---&gt; 0d84ea9a9af5\r\n  Removing intermediate container d9abe719e201\r\n  Step 5\/6 : COPY index.html C:\\site\r\n   ---&gt; b6b3342f2761\r\n  Removing intermediate container 45e11d3a432f\r\n  Step 6\/6 : EXPOSE 8080\r\n   ---&gt; Running in 7f8983d773d5\r\n   ---&gt; f815a0ab0695\r\n  Removing intermediate container 7f8983d773d5\r\n  Successfully built f815a0ab0695<\/pre>\n<p>\u201cmyiis\u201d is the repository name and must be lowercase. At the end of my Dockerfile, I expose my website on the 8080 port number. At this step, I can confirm that my container image has been successfully created:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker images\r\n  REPOSITORY                    TAG                 IMAGE ID            CREATED             SIZE\r\n  myiis                         latest              5b4148e14c8f        45 seconds ago      9.82GB\r\n  microsoft\/iis                 latest              a3dd2dff392b        6 weeks ago         9.82GB\r\n  microsoft\/windowsservercore   latest              4d83c32ad497        7 weeks ago         9.56GB\r\n  microsoft\/nanoserver          latest              d9bccb9d4cac        7 weeks ago         925MB<\/pre>\n<p>Now, I just have to use <strong>Docker run<\/strong> to create a new container from my new container image:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker run -d -p 8080:8080 --name websitecontainer myiis\r\n  PS &gt; docker ps\r\n  CONTAINER ID        IMAGE      [\u2026]    STATUS                  PORTS                    NAMES\r\n  a6a41cf3b19c        myiis      [\u2026]    Up Less than a second   0.0.0.0:8080-&gt;8080\/tcp   websitecontainer <\/pre>\n<p>That\u2019s cool, my container is up and running. I can get the container IP Address with the following command and go to my website on the following URL: http:\/\/172.21.158.179:8080<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' a6a41cf3b19c\r\n  172.21.158.179\r\n  Or\r\n  PS &gt; docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websitecontainer\r\n  172.21.158.179<\/pre>\n<p>Please be careful; because if you begin with Docker and Windows Containers, you will probably make the following mistake: You will try to get the IP address from the image instead of the container. Ensure you get the container ID from <strong>docker ps<\/strong>. if you use the image name, you are asking Docker to show you the IP Address of the image. This, of course, does not make sense, because images do not have IP Addresses.<\/p>\n<h2>Push your images to Docker Hub<\/h2>\n<p>First, you must create a free Docker account here: <a href=\"https:\/\/cloud.docker.com\/\">https:\/\/cloud.docker.com\/<\/a>. Docker Hub lets you store and share your base images. It means that co-workers can use your base image from your repository.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"383\" class=\"wp-image-70204\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-4.png\" \/><\/p>\n<p>You can create repositories and manually\u00a0<a href=\"https:\/\/docs.docker.com\/datacenter\/dtr\/2.2\/guides\/user\/manage-images\/pull-and-push-images\/\">push images<\/a>\u00a0using\u00a0the <strong>docker push<\/strong> command. These repositories can be either public or private. You can create one private repository for free, and unlimited public repositories.<\/p>\n<p>Click on <strong>Repositories<\/strong> and <strong>Create<\/strong>. You must enter a name and an optional description. Next, choose a visibility setting for the repository.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"888\" height=\"818\" class=\"wp-image-70205\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-5.png\" \/><\/p>\n<p>When you need to push an image to Docker Hub, you must use three commands. The first one will tag the image:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker tag f45ecff4c38c getcmd\/lab:latest<\/pre>\n<ul>\n<li><strong>Getcmd<\/strong> is my Docker ID<\/li>\n<li><strong>Lab<\/strong> is my private repository<\/li>\n<li><strong>Latest<\/strong> is the tag<\/li>\n<\/ul>\n<p>Now run the <strong>docker images<\/strong> command to verify that the same image ID now exists in two different repositories.<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker images\r\n  REPOSITORY         TAG            IMAGE ID            CREATED             SIZE\r\n  getcmd\/lab         latest         f45ecff4c38c        2 hours ago         9.89GB\r\n  myiis              latest         f45ecff4c38c        2 hours ago         9.89GB<\/pre>\n<p>The second command stores your credentials using the <strong>docker login<\/strong> command:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker login\r\n  Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https:\/\/hub.docker.com to create one.\r\n  Username: getcmd\r\n  Password:\r\n  Login Succeeded<\/pre>\n<p>Now, you can push the image:<\/p>\n<pre class=\"theme:powershell-output lang:ps decode:true\">PS &gt; docker push getcmd\/lab\r\n  The push refers to a repository [docker.io\/getcmd\/lab]\r\n  0a2abd09b43e: Pushed\r\n  68da241f1f36: Pushed\r\n  26de02533429: Pushed\r\n  12af8be2d3dc: Pushed\r\n  b54f48930406: Pushed\r\n  5b4aace84103: Mounted from microsoft\/iis\r\n  1f2f3eb32edc: Pushed\r\n  0451551dda21: Pushed\r\n  c28d44287ce5: Skipped foreign layer\r\n  f358be10862c: Skipped foreign layer\r\n  latest: digest: sha256:95fa14a4e1af0d8b52ed6dc10c06b6f1085285126ddef2882210dd904de88565 size: 2619\r\n  latest: digest: size: 2619<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"895\" height=\"311\" class=\"wp-image-70206\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2017\/03\/word-image-6.png\" \/><\/p>\n<p>Note: You can log out of Docker Hub using <strong>docker logout<\/strong> command<\/p>\n<h2>Conclusion<\/h2>\n<p>In this article we discussed about the Docker commands that allow you to work with Windows containers. We also download Container images from the Docker HUB, and we have created a free Docker account to store our own images. Next, we have seen how to build our container image and create a container from the container image.<\/p>\n<p>Containerization provides you with an open-ended device that can simplify your deployments in many different ways. In the next article, I will explain how to use Hyper-V Containers, how to convert Windows services to run in a Windows Container, and reveal the mysteries of <strong>Docker-compose<\/strong>.<\/p>\n<p>I hope that this article has helped you to understand more about Windows Containers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Deployments can be made easier, in many different ways, by using Docker and Windows Containers;  but how do you set about working with them? As part of his practical series on Windows Containers and Docker, Nicolas shows how to deploy a Container Host to the Microsoft Azure cloud. retrieve Images from Docker Hub, build your own container image,  and push your images to the Docker Hub. &hellip;<\/p>\n","protected":false},"author":158223,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143513],"tags":[42487,48325],"coauthors":[6804],"class_list":["post-70200","post","type-post","status-publish","format-standard","hentry","category-containers-and-virtualization","tag-dev","tag-windows_containers"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/70200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/158223"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=70200"}],"version-history":[{"count":8,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/70200\/revisions"}],"predecessor-version":[{"id":85654,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/70200\/revisions\/85654"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=70200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=70200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=70200"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=70200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}