Try-This exercise - Push an image to the registry
Use this Try-This exercise to gain some hands-on experience with Azure Kubernetes Service.
For this exercise, Docker commands are used to push a container image into the registry, and finally pull and run the image from your registry.
You must also have Docker installed locally and running. Docker provides packages that easily configure Docker on any Mac, Windows, or Linux system.
Note
To complete this procedure, you need an Azure subscription.
To push an image to an Azure Container registry, you must first have an image. If you don't yet have any local container images, run the following docker pull command to pull an existing public image.
Pull the hello-world
image from Microsoft Container Registry.
docker pull mcr.microsoft.com/hello-world
Before you can push an image to your registry, you must tag it with the fully qualified name of your registry login server. The sign in server name is in the format <registry-name>.azurecr.io (must be all lowercase), for example, newregistryapl.azurecr.io.
Tag the image using the docker tag command. Replace <login-server>
with the login server name of your ACR instance.
docker tag mcr.microsoft.com/hello-world /hello-world:v1
For example:
docker tag mcr.microsoft.com/hello-world newregistryapl.azurecr.io/hello-world:v1
Use docker push to push the image to the registry instance. Replace <login-server>
with the sign-in server name of your registry instance. This example creates the hello-world repository, containing the hello-world:v1 image
.
docker push /hello-world:v1
For example
docker push newregistryapl.azurecr.io/hello-world:v1
After pushing the image to your container registry, remove the hello-world:v1 image
from your local Docker environment. The docker rmi command doesn't remove the image from the hello-world repository in your Azure container registry.
docker rmi /hello-world:v1