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.
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 have created a Azure Container Instance using a yml file where in, I gave a command to run.
command:
- python
- Location to Python file inside the container
I have also attached the Azure File Share as volume so that the, output of the command will be copied to the volume. The container instance gets created successfully and the command runs but the output is not copied to Azure File Share. When i checked in Azure CLI, the status of container is succeeded and the state shows of container is in "waiting".
I tried connecting to the Container using "exec" command in iteractive mode but the terminal was blank for a couple of minutes and there was no response later.
az container exec -g RESOURCE_GROUP_NAME --name CONTAINER_NAME --exec-command "/bin/bash
How to connect to the container in interactive mode and why is command output not copied to Azure File Share ?
Add this header to your Python script
#!/usr/bin/python
and then just execute this script on the container:
az container exec -g RESOURCE_GROUP_NAME --name CONTAINER_NAME --exec-command "/root/your-python-script"
from Azure we try to create container using the Azure Container Instances with prepared YAML.
From the machine where we execute az container create command we can login successfully to our private registry (e.g private.dev on JFrog Artifactory ) after entering password
docker login private.dev -u svc-faselect
Login succeeded
We have YAML file for deploy, and trying to create container using the az command from the SAME server.
az container create --resource-group FRONT-SELECT-NA2 --registry-login-server="private.dev"
--registry-username=svc-faselect --registry-password="..." --file ads-azure.yaml
An error response is received from the docker registry 'private.dev'. Please retry later.
I have only one image in my YAML file.
I am having real big problem to debug why this error is returned since Error response does not provide any useful information.
Search among the similar network issues but without success:
https://learn.microsoft.com/en-us/azure/container-registry/container-registry-troubleshoot-access
I see few moments that could be the reason of your problem.
There should be no = at az container create options
--registry-login-server --registry-password and --registry-username
https://learn.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az_container_create-examples
Command should look like
az container create --resource-group FRONT-SELECT-NA2 --registry-login-server jfrogtraining-docker-dev.jfrog.io --registry-username svc-faselect --registry-password "..." --file ads-azure.yaml
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.
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"