Another nice advantage of using containers is that there are hundreds of images that you can use. Docker has a public database of images that you can access. The Docker Hub repository has images for Microsoft, Unix, Linux, and hundreds more. If you want to see what a vendor has out on the repository, just type docker search vendorname. To see what Microsoft has for you in the repository, type docker search Microsoft (see Figure 12.15).
FIGURE 12.15 docker search Microsoft command
You can set up a private repository so that coworkers can share and use the images that you create. After you create your images using the Docker daemon, you can push those images to your corporate Docker Hub repository. You can add users and accounts to the Docker Hub to verify that only your organization’s users are accessing the images.
If you are building images and placing those images on GitHub or Bitbucket, you can use the automatic build repository that is included with the Docker Hub service.
When you are ready to start uploading corporate images to the Docker Hub, create a Docker Hub user account (https://cloud.docker.com). After you have created your account, click the Create menu and choose Create Repository.
You will then be asked to enter a Docker ID namespace for your organization. The repository name must be unique, and it can be up to 255 characters. The namespace will only allow letters, numbers, or the dash (- ) and underscore (_). You are then asked to enter a short description (100 characters or less) and a dull description. Click Create and you are finished.
After your repository is created, you can push images to the repository by putting in the name of your image, your Docker Hub username, the repository name that you created earlier, and the image tag. The following is an example of the docker push command:
docker push <hub- user>/<repo-n ame>:<tag>
Using Microsoft Azure for Images
Azure containers allow you to easily create, configure, and manage your virtual machine containers. The Azure Container Service uses open source scheduling and management tools. By using open source tools, the Azure Container Service connects you with thousands of other users who are also designing, building, and maintaining container images.
Azure administrators have the ability to manage containers at scale with a managed Kubernetes container management and orchestration service that integrates with Azure Active Directory.
Azure includes the Azure Kubernetes Service (AKS). AKS allows you to quickly and easily start developing and deploying cloud- native apps in Azure, datacenters, or at the edge with built- in code- to- cloud pipelines and guardrails.
AKS gives you the ability to have a unified management and governance system for onsite, edge, and multicloud Kubernetes clusters. You can interoperate with Azure security, identity, cost management, and migration services.
The Azure Container Service uses the Docker format, but it is also compatible with Marathon, DC/OS, Kubernetes, or Docker Swarm. Because the Azure Container Service works with all of these different formats, you can work with thousands of applications and images. But since this is Microsoft Azure’s platform, you get all of the security benefits and features that Azure has to offer.
To set up the Azure Container Service, you must first set up an Azure Container Service cluster through the Azure portal. Once you have entered the portal, use the Azure Resource Manager template for Docker Swarm, DC/OS, and Kubernetes, or use the Azure CLI.
Table 12.5 shows which Azure service you need depending on the container that you want to install. This table was taken directly from Microsoft’s website. For more information, please visit https://azure.microsoft.com/en- us/products/ category/containers.
Using PowerShell for Containers
TABLE 12.5 Azure service and container options
Goal | Azure Option to Use |
Deploy and scale containers on managed Kubernetes | Azure Kubernetes Service (AKS) |
Deploy and scale containers on managed Red Hat OpenShift | Azure Red Hat OpenShift |
Build and deploy modern apps and microservices using serverless containers | Azure Container Apps |
Execute event- driven, serverless code with an end- to- end development experience | Azure Functions |
Run containerized web apps on Windows and Linux | Web App for Containers |
Launch containers with hypervisor isolation | Azure Container Instances |
Deploy and operate always-o n, scalable, distributed apps | Azure Service Fabric |
Build, store, secure, and replicate container images and artifacts | Azure Container Registry |
Using PowerShell for Containers
Table 12.6 contains just some of the PowerShell commands available for using containers and Docker.
TABLE 12.6 PowerShell commands
Add- ContainerNetworkAdapter | This command allows you to add a virtual network adapter to a container. |
Connect- ContainerNetworkAdapter | You can use this command to connect a virtual network adapter to a virtual switch. |
Disconnect- ContainerNetworkAdapter | This command allows you to disconnect a virtual network adapter from a virtual switch. |
Export- ContainerImage | You can use this command to export a container image to a file. |
TABLE 12.6 PowerShell commands (Continued)
Get- Container | This command allows you to view information about containers. | ||
Get- ContainerHost | This command allows you to view information about the host. | ||
Get- ContainerImage | You can use this command to view local container images. | ||
Get- ContainerNetworkAdapter | You can use this command to view the virtual network adapter of a container. | ||
Import- ContainerImage | You can use this command to import a container image from a file. | ||
Install- ContainerOSImage | This command allows you to install the operating system image to a base container. | ||
Install- Module | You can use this command to download a module from an online gallery. This module can then be installed on the local computer. | ||
Install- Package | You can use this command to install a software package on a computer. | ||
Install- PackageProvider | This command allows you to install a Package Management package provider. | ||
Move- ContainerImageRepository | You can use this command to move the local container image repository. | ||
New- Container | This command allows you to create a container image from an existing container. | ||
Remove- Container | You can use this command to delete a container. | ||
Remove- ContainerImage | This command allows you to remove a container image. | ||
Remove- ContainerNetworkAdapter | This command allows you to removes a virtual network adapter from a container. | ||
Restart- Computer | You can use this command to restart a local and remote computer. | ||
PowerShell command | Description | ||
Set- ContainerNetworkAdapter | You can use this command to configure the features of the virtual network adapter within a container. | ||
Start- Container | You can use this command to start a container. | ||
Stop- Container | You can use this command to stop a container. | ||
Test- ContainerImage | This command allows you to test for issues with a container image. | ||
Uninstall- ContainerOSImage | You can use this command to uninstall the container operating system image. |