Add docker-enter script
This commit is contained in:
parent
d26f7c64e8
commit
89f32c5bb9
|
@ -15,7 +15,7 @@ insert_final_newline = true
|
|||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.yml]
|
||||
[*.{yml,yaml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
|
|
27
home/bin/docker-enter
Executable file
27
home/bin/docker-enter
Executable file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# docker-enter: Get inside a docker container, using nsenter.
|
||||
#
|
||||
# Usage: docker-enter <container-id>
|
||||
#
|
||||
# See also:
|
||||
# https://jpetazzo.github.io/2014/03/23/lxc-attach-nsinit-nsenter-docker-0-9/
|
||||
#
|
||||
# --Kirsle
|
||||
# http://sh.kirsle.net/
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
if (scalar(@ARGV) != 1) {
|
||||
die "Usage: $0 <container-id>\n";
|
||||
}
|
||||
|
||||
my $container_id = shift(@ARGV);
|
||||
|
||||
# Get the process ID.
|
||||
chomp(my $pid = `docker inspect --format '{{.State.Pid}}' $container_id`);
|
||||
die "Couldn't get process ID for that container!\n" unless $pid;
|
||||
|
||||
# Enter the docker container.
|
||||
exec("nsenter --target $pid --mount --uts --ipc --net --pid");
|
Loading…
Reference in New Issue
Block a user