Search code examples
azurecontainersdockazure-container-instances

Running commands in azure container instance after container running


I am having code-server container running and I am running az container exec --resource-group resourcename --name code-server --exec-command "ls" it is giving list of files and folder but if we run az container exec --resource-group resourcename --name code-server --exec-command "cd folder" not working showing error like rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"cd Angular\": executable file not found in $PATH"


Solution

  • It's a common issue when you want to execute the commands inside the container instance. This feature does not absolutely support on Azure Container Instance. It only supports the single command and it shows here:

    Azure Container Instances currently supports launching a single process with az container exec, and you cannot pass command arguments. For example, you cannot chain commands like in sh -c "echo FOO && echo BAR", or execute echo FOO.