az container exec: garbage characters inserted at shell prompt
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
When exec'ing a shell in an Alpine-based container running in Azure Container Instances, garbage characters are inserted on key press. In the example output below, the `ls` command is attempted, but `[6;5R` was inserted when the "l" key was pressed, and the command fails:
```console
$ az container exec -g rg604 -n alpine-test-02 --exec-command "/bin/ash"
/ # [6;5Rls
/bin/ash: [6: not found
/bin/ash: 5Rls: not found
/ #
```
**To Reproduce**
1. Start Alpine container in ACI:
```console
$ az container create -g rg604 -n alpine-test-02 --image alpine --command-line "tail -f /dev/null"
```
1. Use `az container exec` to spawn and attach to the `ash` shell in the container:
```console
$ az container exec -g rg604 -n alpine-test-02 --exec-command "/bin/ash"
```
1. Once inside the container, execute the `ls` command to list directory contents:
```console
$ az container exec -g rg604 -n alpine-test-02 --exec-command "/bin/ash"
/ # [6;5Rls
/bin/ash: [6: not found
/bin/ash: 5Rls: not found
/ #
```
Note the characters `[6;5R` were inserted when the "l" key was pressed, causing the `ls` command to fail.
This above example output was from Bash on Ubuntu 18.04, but this behavior also occurs in the Cloud Shell:
```console
marsh@Azure:~$ az container exec -g rg604 -n alpine-test-02 --exec-command "/bin/ash"
/ # [10;5Rls
/bin/ash: [10: not found
/bin/ash: 5Rls: not found
/ #
```
**Expected behavior**
When exec'ed into a container instance, I should be able to enter commands in the terminal without "garbage" characters being inserted on keypress.
**Environment summary**
* Install Method : apt on Ubuntu, and the included `az` on Cloud Shell
* CLI version: 2.0.34
* OS: Ubuntu 18.04 and Cloud Shell
* Shell: bash on Ubuntu and Cloud Shell
**Additional context**
Exec'ing into a locally run Alpine container does not exhibit this behavior:
```console
$ docker run -d alpine tail -f /dev/null
d375353c5f36d6d1bb799df9d9708d9c2e5ec1bfb39080085948d12c052f3665
$ docker exec -it d375353c5f36 /bin/ash
/ # ls
bin etc lib mnt root sbin sys usr
dev home media proc run srv tmp var
/ #
```
Contributor guide
Assessment
This issue has not been assessed yet.