In this post I will detail the quick steps to push and pull a Docker container image from an Azure Container Registry.

Using my Go app, I stopped at building the container and continued from here:

Create the Azure Container Registry

In the Azure portal, browse to the resource group of your choice or create a new one.

Select Create > Containers > Container Registry

I specified the following:

  • Subscription
  • Resource group
  • Registry Name: acrmkmdsn
  • Location: UK South
  • Availability zones: Disabled
  • SKU: Standard

Leave the rest as default and continue on to Create.

Go to the newly created resource and note the Login server is acrmkmdsn.azurecr.io

Create an Admin User for the Container Registry

Open the resource and under Settings select Access Keys

accessKeyOff

Change the Admin user from Disabled to Enabled. Copy the username and one of the passwords.

accessKeyOn

Login to the Container Registry

To login to the container registry from Docker, I ran the following:

docker login acrmkmdsn.azurecr.io

Enter the username and password from the previous step.

dockerLogin

Build and Tag the Container

In the root directory of the dockerfile, I built the container image.

docker build -t go-app .

I then tagged it with the name of go-app and the new container registry

docker tag go-app acrmkmdsn.azurecr.io/go-app

Push the Container to the Registry

To push the container to the registry, complete as follows

docker push acrmkmdsn.azurecr.io/go-app

dockerPush

Back in the Azure portal, under Services select Repositories. Here you can see the newly pushed go-app repo.

repo

And if you select it you can see the go-app:latest image.

latest

Pull the Container Images from the ACR

To pull the image from the Azure Container Registry:

docker pull acrmkmdsn.azurecr.io/go-app:latest

dockerPull

I can then run the container (and remove on stop) as follows:

docker run -d --rm -p 3000:3000 --name go-app acrmkmdsn.azurecr.io/go-app

Can test it is running as expected:

curl localhost:3000

dockerRunCurl

I then ran the following to see that it is running from the ACR image:

docker container ls

dockerContainer

And finally, I can stop the container (which will also remove the container but not the local image) as follows:

docker container stop go-app