Skip to main content

Push Docker Images to Azure Container Registry with GitHub Codespaces

· 2 min read

GitHub Codespaces already have Docker preinstalled as a dependency for the Codespaces environment. This article will guide you through pulling and pushing a Docker image from DockerHub to Azure Container Registry using GitHub Codespaces.

Pushing a container from Docker Hub to your own Azure Container Registry (ACR) can offer several benefits:

  • Security: You can control who can access your container images, and gives you more control over vulnerability scanning.
  • Network latency: You can reduce network latency by hosting your container images closer to your deployment targets.
  • Compliance: You can meet compliance requirements by storing your container images in a specific region.
  • Integration: You can integrate your container images with other Azure services.
info

This article assumes you have an Azure Container Registry already provisioned, you don't need a DockerHub account, if you are pulling from the public repository.

  1. Launch a Codespace, for example: lukemurraynz/Codespace_IaC_Coding Open Codespace
  2. Install the Docker extension for Visual Studio Code in the Codespace
  3. Open the Docker extension and sign in to DockerHub Install Docker Extension
  4. Now we need to log to our Azure Registry; under Registry, select Azure, and connect and log in to your Azure account
  5. Now, we don't have any images, so we need to pull them down from the docker hub. Open the terminal and run the following command:
info

Replace api-firewall:0.6.14 with the image and tag you want to pull from DockerHub.

docker pull api-firewall:0.6.14
  1. Now that our image is pulled down from the Dockerhub, we need to tag it with our Azure Container Registry and push it. We can do this directly from the Docker extension.
  2. Right-click and select Push
  3. Select Azure as the provider, and select your Azure Container Registry
  4. Now, we need to tag the image with the Azure Container Registry to push it. You can adjust the name and Tag and click OK to Push it. Push Azure Container Registry
  5. Now, navigate to your Azure Container Registry in the Azure Portal, and you should see your new image in the repository. Azure Container Registry

You have now successfully pulled and pushed a Docker image from DockerHub to Azure Container Registry using GitHub Codespaces.