Docker in an Azure VM

Microsoft makes it easy to run Docker in Azure. They provide a VM image with Docker installed and configured and with the base Windows images already pulled so you can get started quickly.

For testing and exploring, I always use DevTest labs in Azure. It's a great feature for non-production environments. By default, any VMs you create in a DevTest lab will be turned off every evening, so you don't end up with a big Azure bill from a VM you have used for a few hours and forgotten to turn off.

You can create a DevTest Lab through the Azure portal, and then create a VM from Microsoft's VM image Windows Server 2019 Datacenter with Containers. As an alternative to the Azure portal, you can use the az command line to manage the DevTest lab. I've packaged az in a Docker image, which you can run in a Windows container:

docker container run -it dockeronwindows/ch01-az:2e

This runs an interactive Docker container that has the az command packaged and ready to use. Run az login, and you'll need to open a browser and authenticate the Azure CLI. Then, you can run this in the container to create a VM:

az lab vm create `
--lab-name docker-on-win --resource-group docker-on-win `
--name dow-vm-01 `
--image "Windows Server 2019 Datacenter with Containers" `
--image-type gallery --size Standard_DS2_v2 `
--admin-username "elton" --admin-password "S3crett20!9"

The VM uses the full Windows Server 2019 installation with the UI, so you can connect to the machine with Remote Desktop, open a PowerShell session, and start using Docker right away. Just as with the other options, you can check whether Docker is running with docker version and then run a container from the sample image for this chapter:

docker container run dockeronwindows/ch01-whale:2e 

If an Azure VM is your preferred option, you can follow the steps from the previous section to secure the Docker API for remote access. This way you can run the Docker command line on your laptop to manage containers on the cloud. The Azure VM deploys Docker using PowerShell, so you can update the Docker Engine on your VM using the InstallPackage ... -Update command from the previous section.

All these options – Windows 10, Windows Server 2019, and the Azure VM – can run the exact same Docker images with the same result. The sample application in the Docker image, dockeronwindows/ch01-whale:2e, behaves in the same way on every environment.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.134.130