4
votes

Is there a way to execute a command in a container hosted in ACI? I'm looking for something like this:

docker container exec [image] [command]
3

3 Answers

2
votes
az container exec --resource-group myResourceGroup --name <name of cotainer group> --container-name <name of container app> --exec-command "/bin/bash"

Source Execute Commands in Azure Container Instances

1
votes

You can use the Azure CLI tools, with a command like:

az container exec -g container-group --name container-name --exec-command "/bin/bash"

For more information, see this document: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-exec

However, I've noticed that I currently cannot select the user to run the command as (such as docker exec -u "user").

0
votes

Not yet, but it's on our list. For the moment, the best you can do is SSHing into the container and running your command that way.