unable to run dialog in a container

colmconn

New Member
Dec 29, 2025
1
0
1
Hey,

I hav created and (alpine 3.23) backed container and installed bash and dialog in it. When I try to run the simple script below, the dialog command fails with

cannot open tty-output

(I've successfully run this simple script in macos 15.7.3, ubuntu 24.04.3, and

proxmox-ve: 9.1.0 (running kernel: 6.17.4-1-pve)).

Can anyone advise on how I can get dialog to work in a container?

Thank in advance.

Bash:
#!/bin/bash

USER_INPUT=$(dialog --output-fd 1 --title "User Input" --backtitle "LXC Demo" \
  --inputbox "Enter a value:" 10 40 )
#echo ${USER_INPUT}

# Check the exit status of the dialog command (0 for OK, 1 for Cancel)
if [ $? -eq 0 ]; then
  echo "Captured input: $USER_INPUT"
else
  echo "User cancelled input."
fi

The container config is
INI:
arch: amd64
cmode: console
cores: 1
entrypoint: /bin/sh
env: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
features: nesting=1
hostname: test-ct
memory: 1024
nameserver: 192.168.1.1
net0: name=eth0,bridge=vmbr0,gw=192.168.1.1,host-managed=1,ip=192.168.36.191/16,type=veth
onboot: 1
ostype: alpine
rootfs: local-lvm:vm-104-disk-0,size=1G
searchdomain: home
startup: 3
swap: 0
timezone: America/New_York
unprivileged: 1
lxc.init.cwd: /
lxc.signal.halt: SIGTERM
 
You'll probably have to run strace and inspect its output to really find out what's not working. Since you have a rather slim Alpine installation, there might be some terminal ownership handling (or similar) missing. Only way to really find out is to hack at it with strace.

One thing you could try right off the bat is redirecting stdout and stderr to /dev/tty, like so:
Bash:
dialog $OPTS 2>&1 > /dev/tty