Training
Module
Run container images in Azure Container Instances - Training
Run container images in Azure Container Instances
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Azure Container Instances supports executing a command in a running container. Running a command in a started container is especially helpful during application development and troubleshooting. The most common use of this feature is to launch an interactive shell so that you can debug issues in a running container.
Execute a command in a running container with az container exec in the Azure CLI:
az container exec --resource-group <group-name> --name <container-group-name> --exec-command "<command>"
For example, to launch a Bash shell in an Nginx container:
az container exec --resource-group myResourceGroup --name mynginx --exec-command "/bin/bash"
In the following example output, the Bash shell is launched in a running Linux container, providing a terminal in which ls
is executed:
root@caas-83e6c883014b427f9b277a2bba3b7b5f-708716530-2qv47:/# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
root@caas-83e6c883014b427f9b277a2bba3b7b5f-708716530-2qv47:/# exit
exit
Bye.
In this example, Command Prompt is launched in a running Nanoserver container:
az container exec --resource-group myResourceGroup --name myiis --exec-command "cmd.exe"
Microsoft Windows [Version 10.0.14393]
(c) 2016 Microsoft Corporation. All rights reserved.
C:\>dir
Volume in drive C has no label.
Volume Serial Number is 76E0-C852
Directory of C:\
03/23/2018 09:13 PM <DIR> inetpub
11/20/2016 11:32 AM 1,894 License.txt
03/23/2018 09:13 PM <DIR> Program Files
07/16/2016 12:09 PM <DIR> Program Files (x86)
03/13/2018 08:50 PM 171,616 ServiceMonitor.exe
03/23/2018 09:13 PM <DIR> Users
03/23/2018 09:12 PM <DIR> var
03/23/2018 09:22 PM <DIR> Windows
2 File(s) 173,510 bytes
6 Dir(s) 21,171,609,600 bytes free
C:\>exit
Bye.
If your container group has multiple containers, such as an application container and a logging sidecar, specify the name of the container in which to run the command with --container-name
.
For example, in the container group mynginx are two containers, nginx-app and logger. To launch a shell on the nginx-app container:
az container exec --resource-group myResourceGroup --name mynginx --container-name nginx-app --exec-command "/bin/bash"
Azure Container Instances currently supports launching a single process with az container exec, and you can't pass command arguments. For example, you can't chain commands like in sh -c "echo FOO && echo BAR"
, or execute echo FOO
.
Learn about other troubleshooting tools and common deployment issues in Troubleshoot container and deployment issues in Azure Container Instances.
Training
Module
Run container images in Azure Container Instances - Training
Run container images in Azure Container Instances
Documentation
Manually stop or start container group - Azure Container Instances
Learn how to manually stop or start a container group in Azure Container Instances.
Troubleshoot common issues - Azure Container Instances
Learn how to troubleshoot common issues when your deploy, run, or manage Azure Container Instances
Override entrypoint in container instance - Azure Container Instances
Set a command line to override the entrypoint in a container image when you deploy an Azure container instance