I am new to Docker and am trying to successfully run the image below to run a Perl script that opens a simple Perl Tk window.
The Image:
FROM debian:bullseye
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y cpanminus perl-tk x11-xserver-utils
COPY Tk_hello_world.pl /opt/
CMD perl /opt/Tk_hello_world.pl
The Perl script Tk_hello_world.pl
use strict;
use Tk;
my $mw = MainWindow->new;
$mw->title("Hello World");
$mw->Button(-text => "Done", -command => sub { exit })->pack;
MainLoop;
The image builds successfully but when I try to run the container I get:
couldn't connect to display ":0" at /usr/lib/x86_64-linux-gnu/perl5/5.32/Tk/MainWindow.pm line 53.
MainWindow->new() at /opt/Tk_hello_world.pl line 3.