My Unix config files and shell scripts, optimized for Fedora, Debian, macOS and Windows (in that order).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
629 B

# docker-enter: Get inside a docker container, using nsenter.
# Usage: docker-enter <container-id>
# See also:
# --Kirsle
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");