Skip to content

Commit fdb7bdf

Browse files
committed
Better container views
1 parent 6a5d40c commit fdb7bdf

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docker/container.cgi

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ our (%in);
1111
my $container = $in{'container'};
1212
my $tab = $in{'tab'};
1313

14-
ui_print_header(undef, text('view_container_title', $container), "", undef, undef, $in{'nonavlinks'});
14+
my ($code, $container_name) = get_container_attr($container, 'Name');
15+
if ($code) { # Bad container id
16+
ui_print_header(undef, text('view_container_title', "not found"), "", undef, undef, $in{'nonavlinks'});
17+
&ui_print_endpage(ui_alert_box($code, 'danger'), "Back", "/");
18+
}
1519

20+
# Trim leading /
21+
$container_name = substr $container_name, 1;
22+
ui_print_header(undef, text('view_container_title', $container_name), "", undef, undef, $in{'nonavlinks'});
1623

1724
my @tabs = ( [ 'log', &text('tab_log') ],
1825
[ 'inspect', &text('tab_inspect') ] );

docker/docker-lib.pl

+12
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,18 @@ sub get_containers
6767
return 0, @results;
6868
}
6969

70+
sub get_container_attr
71+
{
72+
my($container, $attr) = @_;
73+
my ($code, $result) = docker_command('inspect --type=container ' . $container, '{{.' . $attr . '}}');
74+
if ($code != 0) {
75+
print "Bang";
76+
return $result;
77+
}
78+
79+
return 0, $result;
80+
}
81+
7082
sub get_stats
7183
{
7284
my ($code, $result) = docker_command('stats --all --no-stream', '{{.ID}},{{.CPUPerc}},{{.MemPerc}},{{.MemUsage}}');

0 commit comments

Comments
 (0)