Executing simple admin tasks in a container
In this section, we want to provide a few examples of tasks you may want to run in a container instead of natively on your computer.
Running a Perl script
Let’s assume you need to strip all leading whitespaces from a file and you found the following handy Perl script to do exactly that:
$ cat sample.txt | perl -lpe 's/^\s*//'
As it turns out, you don’t have Perl installed on your working machine. What can you do? Install Perl on the machine? Well, that would certainly be an option, and it’s exactly what most developers or system admins do. But wait a second, you already have Docker installed on your machine. Can’t we use Docker to circumvent the need to install Perl? And can’t we do this on any operating system supporting Docker? Yes, we can. This is how we’re going to do it:
- Navigate to the chapter’s code folder:
$ cd ~/The-Ultimate-Docker-Container-Book/ch08
...