> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# 运行 docker exec 报错 the input device is not a TTY
- URL: https://sgpublic.xyz/p/2024/01/6aac9cb1810a4800015335f7/
- Published: 2024-01-11T09:40:20.000Z
- Updated: 2024-01-11T09:40:20.000Z
- Author: Haven Madray
- Tags: 基础设施, Docker, #wp-post

在使用 docker in docker 时，在容器内执行命令刷新 nginx：

```
docker exec -it nginx-nginx-1 nginx -s reload

```

结果一直报错：

```
the input device is not a TTY

```

查阅帮助文档：

```
madray@pve:/mnt/core/app/nginx/conf.d$ docker exec --help

Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Execute a command in a running container

Aliases:
  docker container exec, docker exec

Options:
  -d, --detach               Detached mode: run command in the background
      --detach-keys string   Override the key sequence for detaching a container
  -e, --env list             Set environment variables
      --env-file list        Read in a file of environment variables
  -i, --interactive          Keep STDIN open even if not attached
      --privileged           Give extended privileges to the command
  -t, --tty                  Allocate a pseudo-TTY
  -u, --user string          Username or UID (format: "[:]")
  -w, --workdir string       Working directory inside the container

```

显然，`-t` 参数需要当前环境支持 TTY，而默认情况下容器不支持 TTY，因此将 `-t` 参数移除即可：

```
docker exec -i nginx-nginx-1 nginx -s reload

```