Rex::Box::Docker(3)

πŸ“¦ version 1.14.3, in nixos 26.05, nixpkgs unstable

πŸ’… Rex::Box::Docker(3) β€” the perl doc you actually wanna read 🐳

okay so bestie, you found the Rex::Box::Docker page in the perl docs (User Contributed Perl Documentation, no less πŸ‘‘) and you're like "what is this". Don't worry, I got you. This is the Rex/Boxes module for using Docker Images, and yeah β€” you gotta have dockerd installed first, no cap. πŸ’–


πŸ¦‹ NAME

Rex::Box::Docker β€” the Rex/Boxes Docker Module, fr fr.

✨ DESCRIPTION

This is a Rex/Boxes module to use Docker Images. That's the whole vibe. But listen β€” you need to have dockerd installed. Like, actually installed and running. Not optional, bestie. πŸ’…


πŸŽ€ EXAMPLES

So say you wanna use this module inside your Rexfile β€” here's exactly how, no guessing:

use Rex::Commands::Box;
set box => "Docker";

task "prepare_box", sub {
   box {
      my ($box) = @_;

      $box->name("mybox");
      $box->url("http://box.rexify.org/box/ubuntu-server-12.10-amd64.tar.gz");
      $box->url("debian:latest");

      $box->network(1 => {
         name => "default",
      });

      $box->auth(
         user => "root",
         password => "box",
      );

      $box->setup("setup_task");
   };
};

Look at that. Two url calls, a network with name => "default", auth with user => "root" and password => "box", and a setup pointing at "setup_task". Icons only. ✨


Now if you're more of a YAML girlie (and honestly, same), here's the template πŸ“:

type: Docker
vms:
   vmone:
      url: debian:latest
      setup: setup_task

And then in your Rexfile you just do this and it slays:

use Rex::Commands::Box init_file => "file.yml";

task "prepare_vms", sub {
   boxes "init";
};

The init_file => "file.yml" is doing the heavy lifting there, just so we're clear. πŸ’œ


πŸ’€ METHODS

First things first: see also the Methods of Rex::Box::Base. This module inherits all methods of it. So if you can't find what you need here, that's where it's at. iykyk 🫢

πŸ’… new(name => $vmname)

Constructor if used in OO mode. That's object-oriented mode, for the uninitiated. 🌸

my $box = Rex::Box::Docker->new(name => "vmname");

🧚 memory($memory_size)

Sets the memory of a VM in megabyte. Yes, megabyte. Singular. That's what it says, bestie. ⭐

πŸ”₯ info

Returns a hashRef of vm information. A hashRef, not a hash. Don't come for me, I'm just the messenger. πŸ’–

🌈 ip

This method return the ip of a vm on which the ssh daemon is listening. That's the ip you want if you're trying to ssh in β€” it's giving main character energy. πŸ‘‘

lowkey important: the ssh daemon is the thing listening, so if you're not running one, this ip isn't gonna do you any favors 😭

aaaand that's the whole page, bestie. Not me being obsessed with how short and sweet this one is πŸ’€

Signed off with love: this page is perl v5.42.3, dated 2023-08-05, and it's Rex::Box::Docker(3) β€” catch you in the group chat πŸŽ€πŸ’–

πŸ“¦ where this page comes from