Is it possible to start docker containers in Azure with the docker --tty argument through the Azure Command-line Interface? I see nothing in the documentation and I'd like to be able to attach to a tmux session.
I think you want to add the parameter --tty is to create a terminate and interact with the container instance. But it's not a parameter supported by Azure Container Instance. You can see all the supported parameters in CLI commands az container. To create a terminate and interact with the container instance, you could use the CLI command az container exec to achieve it, just like:
az container exec -g MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash"
Related
I'm running Linux and I've pushed several docker containers up to azure as container instances. My containers seem to be working fine, all services provided by the containers are working. But when I run the az container exec command nothing happens, no error message.
I'm running:
az container exec --subscription mySubscription --resource-group myResource --name myContainer --exec-command "ls"
and then nothing...
When I put in a wrong container name I get an error, so I know that I'm reaching the container. I'm out of ideas about how to see what's going wrong, I would just say forget it and just do an ssh connection but there doesn't seem to be a way to do that.
Any help would be appreciated, thanks.
Check and see if a firewall is blocking port 19390. Opening this port might be a requirement for this command to work, although I cannot confirm this in the Microsoft documentation:
https://learn.microsoft.com/en-us/answers/questions/753676/what-ports-must-be-allowed-in-a-firewall-configura.html
Have you tried launching a bash shell with your container? Try the following command:
az container exec --resource-group myResourceGroup --name myContainer --exec-command "/bin/bash"
Once you're the bash session is running, simply run the commands you want to:
root#caas-83e6c883014b427f9b277a2bba3b7b5f-708716530-2qv47:/# ls
I'm trying to remotely interact with a container instance in Azure.
I've performed following steps:
Loaded local image on local registry
docker load -i ima.tar
Loggin in to remote ACR
docker login --username --password + login-server
Tagged the image
docker tag local-image:tag <login-server/repository-name:tag>
Pushed imaged
docker push <login-server/repository-name:tag>
If I try to run a command like this:
az container exec --resource-group myResourceGroup --name <name of cotainer group> --container-name <name of container app> --exec-command "/bin/bash"
I can successfully login to bash interactively.
My Goal is to process local file to the a remote ACI using the ACR image, something like this:
docker run -t -i --entrypoint=./executables/run.sh -v "%cd%"\..:/opt/test remote_image:tag
Is it there a way to do so? How can I run ACI e remote push file via AZ CLI?
Thx
For your purpose, I recommend you mount the Azure File Share to the ACI and then upload the files to the File Share. Finally, you can access the files in the File Share inside the ACI. Follow the steps here to mount the File Share.
I am running an R Shiny app inside a container in Azure Container Instance. Via a DevOps pipeline whenever I change the source code of my App, I recreate the container in the Build pipeline and update the Container Instance via an Azure Cli command in the Release pipline via az container create and az container restart.
After spinning it up I need to run a bash command - namely, automatically adjusting a file within the created container.
In local Docker this would be
docker exec {containerName} /bin/bash -c "echo `"var1 = \`"val1`"`" >> /home/shiny/.Renviron"
This means: run a bash command in the container to push some text into the .Renviron file within the container.
Now the Azure Container Instance says you cannot pass command arguments for az container exec: https://learn.microsoft.com/en-us/azure/container-instances/container-instances-exec
How would you then in an automated build/release process in Azure go for building, releasing and configuring a container?
I do not want to set those values within the build pipeline as I want to use the same image for different staging areas setting those values accordingly.
Many thanks in advance for your help.
I am very new to azure container instances, so I may not understand your aims but it seems another way of achieving this:
I do not want to set those values within the build pipeline as I want
to use the same image for different staging areas setting those values
accordingly.
could be to modify your parameter values upon container creation using the --command-line flag mentioned here. Something like
az container create -g MyResourceGroup --name myapp --image myimage:latest --command-line "/bin/sh -c '/path to/myscript.sh val1 val2'"
in which myscript.sh runs your app with the indicated values.
Is it possible to execute command in a container which is running under Azure WebApp service by Docker Compose?
When I create single container by az container create ..., then it works.
But when I create set of containers by Docker compose script using az webapp create --multicontainer-config-type compose ..., then it does not work.
From logs I see that there is running container myWebApp_myContainer_1 so I try:
az container exec -g myResourceGroup -n myWebApp_myContainer_1 --exec-command "/bin/bash"
With this result:
The Resource 'Microsoft.ContainerInstance/containerGroups/myWebApp_myContainer_1'
under resource group 'myResourceGroup' was not found.
Then I try:
az container exec -g myResourceGroup -n myWebApp --container-name myWebApp_myContainer_1 --exec-command "/bin/bash"
With this result:
The Resource 'Microsoft.ContainerInstance/containerGroups/myWebApp' under resource group 'myResourceGroup' was not found.
Note that it is normally possible to execute commands in containers started by Docker compose script on local Docker (out of Azure).
Update I don't like to install SSH server into Docker images. It is a bad approach. I'm looking for a way of direct exec like az container exec does.
Thank you for any hint.
For your issue, when the web app created from a Docker image, it's just a web app, not a container. So you cannot use the command az container exec to connect to it.
If you really want to connect to the web app that created from a Docker image, there are two ways as I know to achieve it.
The one is that I describe in the comment, you should install the OpenSSH server in the Docker image. Then ssh into the web app from the port exposed to the Internet.
The other one as you wish is using the command az webapp remote-connection. For more details, you can read Open SSH session from remote shell.
I am working with Azure Container Instance group.. and one of my containers is constantly restarting.. it goes to a terminated state and restarts. Everything looks good in logs.. The container is running a spring framework + React application. When I run the containers locally.. it works perfectly.
Am not sure what is happening behind the scenes?
You could use Azure CLI to set a restart policy of OnFailure or Never.
az container create \
--resource-group myResourceGroup \
--name mycontainer \
--image mycontainerimage \
--restart-policy OnFailure
If you specify the restart policy and the issue still exists,there might be some problems with the application or script executed in your container. You could use az container show command to check the restartCount property.
az container show --name
--resource-group
For more details, refer to this article.