Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

To dockerize an app and deploy it to Azure Container Instances (ACI) with Docker Hub, package the app in a Docker image, test it locally, push a versioned image to Docker Hub, then create an ACI container that uses that exact image and the app’s listening port. The Dockerfile and deployment values depend on your app, so replace the examples below with its actual build process, startup command, port, and resource needs.

What you need to decide first

A Docker image packages an application and its runtime dependencies; a container is a running instance of that image. Docker Hub is a registry for sharing images. The image moves from your computer to Docker Hub, then ACI pulls it to start the container.

  • Application build: determine whether the app runs directly or must first be compiled, and which runtime version it needs.
  • Listening port: identify the port the app actually listens on inside the container. The port ACI exposes must match it.
  • Image visibility: a public Docker Hub repository can be pulled without private-registry credentials; a private one requires ACI authentication.
  • Access: decide whether the app needs an internet-accessible endpoint. A public DNS label and exposed port make a web app reachable from outside Azure.
  • Runtime settings: establish any required environment variables, persistent storage, CPU and memory needs, operating system, and Azure region before deployment.

Microsoft’s Docker container training module describes creating a Dockerfile from a starter image, adding files, configuring startup, and building and running the result. Its steps are a useful framework, but the actual Dockerfile must fit your application.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Create a Dockerfile for your application

In your project directory, create a file named Dockerfile (with no file extension). It needs a suitable base image, instructions to copy or build the app, any necessary runtime dependencies, and a startup command. There is no universal Dockerfile: a compiled app may need a build stage, while an interpreted app may run from its source files.

Use the following as a planning outline, not as a copy-and-run Dockerfile: select the app’s runtime base image; add the project files; install only the dependencies needed at runtime; configure the app’s startup command; and ensure it listens on the port you intend to expose. The language, build system, and startup command are not specified here, so choose those from your app’s own requirements.

Do not put passwords, API keys, or other secrets into the image. A published image may be accessible to anyone if its Docker Hub repository is public. Configure secrets through an appropriate runtime mechanism instead.

Build and test the image locally

Run Docker commands from the directory containing the Dockerfile. Replace YOUR_DOCKERHUB_ID, YOUR_REPOSITORY, VERSION, and APP_PORT with your own values. Choose a meaningful version tag so you can identify the exact build deployed; do not rely on an unspecified moving tag.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
docker build -t YOUR_DOCKERHUB_ID/YOUR_REPOSITORY:VERSION .
docker run --rm -p APP_PORT:APP_PORT YOUR_DOCKERHUB_ID/YOUR_REPOSITORY:VERSION

For the local run, the left side of -p is the port on your computer and the right side is the port inside the container. They may differ if needed; the container-side port must be the one the app listens on. Visit the corresponding local address in a browser or send a request with an HTTP client. If startup fails or the app is unreachable, check the Docker build output, startup command, app logs, and port mapping before publishing.

Push the image to Docker Hub

Create a Docker Hub repository and decide whether it should be public or private. Sign in to Docker using the current Docker CLI authentication guidance, then tag and push the image using the same account, repository, and version that you plan to deploy:

docker tag YOUR_DOCKERHUB_ID/YOUR_REPOSITORY:VERSION YOUR_DOCKERHUB_ID/YOUR_REPOSITORY:VERSION
docker push YOUR_DOCKERHUB_ID/YOUR_REPOSITORY:VERSION

The tag command above makes the naming step explicit; if you built the image with that exact name and tag, it already has the deployment reference. The push uploads that tagged image to Docker Hub. Docker’s Docker CLI cheat sheet explains the distinction between images and running containers and describes Docker Hub’s image-sharing role.

Keep the full image reference, including the version tag. You will use it in ACI’s create command. For a private repository, also prepare Docker Hub authentication for ACI rather than assuming a successful local push means Azure can pull the image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Deploy the image to ACI with Azure CLI

Install and sign in to the Azure CLI, then choose a resource group, Azure region, container name, app port, and—if public access is needed—a unique DNS label. Microsoft’s Azure CLI quickstart for ACI uses a resource group and az container create, and demonstrates log retrieval and cleanup. It was marked last updated November 17, 2025; confirm current command options and regional availability in Microsoft Learn before deployment.

For a public Docker Hub image and an app intended to be reachable over the internet, the command pattern is:

az group create --name YOUR_RESOURCE_GROUP --location YOUR_AZURE_REGION
az container create 
  --resource-group YOUR_RESOURCE_GROUP 
  --name YOUR_CONTAINER_NAME 
  --image YOUR_DOCKERHUB_ID/YOUR_REPOSITORY:VERSION 
  --dns-name-label YOUR_UNIQUE_DNS_LABEL 
  --ports APP_PORT

Substitute a real region and globally unique DNS label, and use the exact image reference pushed to Docker Hub. The port must match the app’s in-container listening port. Microsoft’s quickstart also uses CPU and memory settings; select values appropriate to your workload rather than copying demo values blindly. Do not add a public DNS label or open a public port if the application does not need internet access.

For a private Docker Hub repository

ACI must authenticate to pull a private image. Supply the Docker Hub registry login details using the authentication options supported by the current Azure CLI. Microsoft’s guidance identifies Docker Hub as the registry and docker.io as its login server for private-image pulls. Use a suitable Docker Hub credential or token, protect it, and avoid placing secrets in a script, shared command history, or source-controlled file. Consult Microsoft’s private registry guidance for the supported registry-authentication approach; it discusses private registry pulls, including Docker Hub.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

CLI or PowerShell

Microsoft also publishes a PowerShell quickstart for deploying a Docker container to ACI. Use one shell’s command set from start to finish: CLI examples use shell continuation characters and syntax that do not necessarily work unchanged in PowerShell.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check that the deployment works

A successful create operation confirms provisioning, not that the app serves requests correctly. Check the container’s state and logs, then make a real request to the assigned endpoint.

  1. Inspect the container group and confirm its provisioning state is successful.
  2. Retrieve the container logs using the Azure CLI command shown in the ACI CLI quickstart. Look for startup errors, missing configuration, or a port mismatch.
  3. If you configured a public DNS label and port, test the resulting endpoint from a browser or HTTP client. Use the appropriate protocol and port for your app.
  4. If it fails, verify that the image reference and tag exist in Docker Hub, that ACI can authenticate if the repository is private, and that the exposed port matches the app’s listener.

Clean up when finished

Delete the container when you no longer need it. Remove the resource group only if it contains no other resources you want to keep; deleting a resource group removes its contained resources. The Azure CLI quickstart demonstrates cleanup commands.

When Azure Container Registry may fit better

Docker Hub works for this workflow, but Azure Container Registry (ACR) is another option for hosting private images in an Azure-focused deployment. Microsoft’s private-registry guidance covers ACR as well as Docker Hub authentication. ACR is an alternative, not a required step: if you choose Docker Hub, keep the Docker Hub image reference consistent from push through ACI deployment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.