How To Deploy Containers to Azure ACI using Docker CLI and Compose

December 8, 2025 · 1378 words · 7 min

Running containers in the cloud can be hard and confusing. There are so many options to choose from

Running containers in the cloud can be hard and confusing. There are so many options to choose from and then understanding how all the different clouds work from virtual networks to security. Not to mention orchestrators. It’s a learning curve to say the least. At Docker we are making the Developer Experience (DX) more simple. As an extension of that we want to provide the same beloved Docker experience that developers use daily and integrate it with the cloud. Microsoft’s Azure ACI provided an awesome platform to do just that. In this tutorial, we take a look at running single containers and multiple containers with Compose in Azure ACI. We’ll walk you through setting up your docker context and even simplifying logging into Azure. At the end of this tutorial, you will be able to use familiar Docker commands to deploy your applications into your own Azure ACI account. To complete this tutorial, you will need: The integration with Azure ACI is very similar to working with local containers. The development teams have thought very deeply about the developer experience and have tried to make the UX for working with ACI as close as possible to working with local containers. Let’s run a simple Nginx web server on Azure ACI. You do not need to have the Azure CLI installed on your machine to run Docker images in ACI. Docker takes care of everything. The first thing you need to do is to login to Azure. This will open a browser window which will allow you to login to Azure. Select your account and login. Once you are logged in, you can close the browser window. Docker has the concept of a context. You can think of a context as a place where you can run docker containers.It’s a little more complicated than this but this is a good enough description for now. In this tutorial, we use our local context and the new ACI context. Let’s first take a look at what contexts we currently have on our local development machine. Run the following command to see a list of contexts. Depending on if you have already created another context, you should only see one context. This is the default context that points to your local Docker engine labeled as “moby”. You can identify the current context that will be used for docker commands by the “*” beside the name of the active context. Now let’s create an ACI context that we can run containers with. We’ll use the create aci command to create our context.  Let’s take a look at the help for creating an aci context. Underneath the section of the help, you can see that we have the option to set the , and You can pass these flags into the create command. If you do not, the docker cli will ask you these questions in interactive mode. Let’s do that now. The first thing the cli will ask is what subscription you would like to use. If you only have one then docker will use that one. Now we need to select the resource group we want to use. You can either choose one that has been previously created or choose “create a new resource group”. I’ll choose to create a new one. Okay, our aci context is set up. Let’s list our contexts. You should see the ACI context you just created. Now that we have our ACI context set up, we can now run containers in the cloud. There are two ways to tell Docker which context you want your commands to be applied to.  The first is to pass the flag. The other is to tell Docker which context we want to use with all subsequent commands by switching contexts. For now, let’s use the –context flag. Here you can see that Docker interacted with ACI and created a container instance named “web” and started a single instance. Open your Azure portal and navigate to container instances. We can also run Docker CLI commands that you are already familiar with such as ps and logs. Let’s take a look at our running containers. But before we do that let’s switch our active context to the ACI context we setup above so we do not have to keep typing –context with every command. Now let’s run the ps command without passing the –context flag. Nice, since we told Docker to use the myaci context, we see a list of containers running in our Azure account and not on our local machine. Let’s make sure our container is running. Copy the IP address of the container from the above ps output and paste it into your browser address bar. You can see our Nginx web server running! Like I mentioned above, we can also take a look at the container’s logs.  To stop and remove the container, run the following command. That was pretty easy and the integration is smooth. With a few docker commands that you are already familiar with and a couple new ones, we were able to run a container in ACI from our development machine pretty quickly and simply. But we’re not done! We can also run multiple containers using Docker Compose. With the ACI integration, we now have the ability to run compose commands from the docker cli against ACI. Let’s do that next. I’m using a simple Python Flask application that logs timestamps to a Redis database. Let’s fork the repository and then clone the git repository to your local machine. Open your favorite browser and navigate to: Click on the “fork” button in the top right corner of the window. This will make a “copy” of the demo repository into your GitHub account. On your forked version of the repository, click the green “Code” button and copy the github url. Open up a terminal on your local machine and run the following git command to clone the repository to your local development machine. Make sure you replace the with your GitHub username. Make sure you are in the root directory for the timestamper project and follow the following steps to build the images and start the application with Docker Compose. First we need to add your Docker ID to the image in our docker-compose.yml file. Open the docker-compose.yml file in an editor and replace «username» with your Docker ID. Next, we need to make sure we are using the local Docker context. Now we can build and start our application using docker-compose. Docker will build our timestamper image and then run the Redis database and our timestamper containers. Navigate to http://localhost:5000 and click the Timestamp! button a couple of times. Now let’s run our application on ACI using the new docker compose integration. We’ll first need to push our image to Docker Hub so ACI can pull the image and run it. Run the following command to push your image to your Docker Hub account. Now that our image is on Hub, we can use compose to run the application on ACI. First let’s switch to our ACI context. Remember, to see a list of contexts and which is being used, you can run the list contexts command. Okay, now that we are using the ACI context, let’s start our application in the cloud. Let’s verify that our application is up and running. To get the IP address of our frontend, let’s list our running containers. Copy the IP address and port listed above and paste into your favorite browser. Let’s take a look at the logs for our Redis container. Yes, sir! That is a Redis container running in ACI! Pretty cool. After you play around a bit, you can take down the compose application by running compose down. We saw how simple it is now to run a single container or run multiple containers using Compose on Azure with our ACI integration. If you want to help influence or suggest features, you can do that on our public . If you want to learn more about Compose and all the cool things that are happening around the OpenSource initiative, please checkout and the OpenSource .