Azure / Azure/azure-cli

az container exec: Not a tty

Open
#17,530 9 comments 4 reactions 0 assignees View on GitHub
act-observability-squad Container Instances Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Describe the bug**
I'm running `az container exec` on our CI/CD inside a docker container to test my app. az cli throws this exception because there is no tty:
```
CLIInternalError: The command failed with an unexpected error. Here is the traceback:
(25, 'Not a tty')
Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/knack/cli.py", line 215, in invoke
cmd_result = self.invocation.execute(args)
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
raise ex
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 717, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 710, in _run_job
six.reraise(*sys.exc_info())
File "/usr/lib/python3.8/site-packages/six.py", line 703, in reraise
raise value
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 688, in _run_job
result = cmd_copy(params)
File "/usr/lib/python3.8/site-packages/azure/cli/core/commands/__init__.py", line 325, in __call__
return self.handler(*args, **kwargs)
File "/usr/lib/python3.8/site-packages/azure/cli/core/__init__.py", line 784, in default_command_handler
return op(**command_args)
File "/usr/lib/python3.8/site-packages/azure/cli/command_modules/container/custom.py", line 623, in container_exec
_start_exec_pipe(execContainerResponse.web_socket_uri, execContainerResponse.password)
File "/usr/lib/python3.8/site-packages/azure/cli/command_modules/container/custom.py", line 657, in _start_exec_pipe
oldtty = termios.tcgetattr(sys.stdin)
termios.error: (25, 'Not a tty')
```
I can't add a tty because it runs inside our CI/CD.

Similar to this issue https://github.com/Azure/azure-cli/issues/15225

**To Reproduce**

Run az cli inside a container without attching tty (-t) and then run `az container exec`
```
docker run mcr.microsoft.com/azure-cli az container exec --resource-group $RG --name $ACI_NAME --exec-command "ls -la"
```

**Expected behavior**
`az container exec` should also work without a tty.
In docker I have to explicitly add `-t` to enable tty but with `az container exec` it's allways enabled.

**Environment summary**

* GitLab runner container
* az cli 2.16.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.