Using Rakudo Perl 6 in a Docker container

Docker allows the creationg of small Linux containers that can make building environments and deploying applications easy. Let's see how can we use Rakudo with a Docker image.

Note! This site is about Perl 6.
If you are looking for a solution for Perl 5, please check out the Perl 5 tutorial.

There is a Docker image for Rakudo Star we can easily us to develop Perl 6 code.

Install Docker

Perl 6 one-liner

$ docker run rakudo-star perl6 -e 'say "Hello!"'

Perl 6 script

Create a file locally on your host system called "" with the following content:

use v6;
say "Hello from Perl 6";

and then run it as:

docker run -v $(pwd):/opt rakudo-star perl6 /opt/

The flag -v $(pwd):/opt will map the current working directory of your host machine to the /opt directory of the Docker container. If you have the "" file in the current directory then it will be accessible by the container as "/opt/".

If you are running on an MS Windows machine then you'll probably write this:

docker run -v %cd%:/opt rakudo-star perl6 /opt/

Perl 6 REPL

If you'd like to explore Perl 6 using the interactive shell you can type the following:

docker run  -it rakudo-star

It will run Perl 6 and show you a prompt:

To exit type 'exit' or '^D'

At this point you can type in some Perl 6 code:

say "hello"

Once you are done, you can leave the shell and close the Docker container using:


Cleaning up after yourself

Docker will leave behind the exited containers. You can list them using:

docker ps -a

You can remove them with

docker rm $(docker ps -a -q)


Alternatively, include the --rm flag in the command line options of docker run and then the containers will be removed when they are exited.

for example:

$ docker run --rm rakudo-star perl6 -e 'say "Hello!"'


$ docker run --rm rakudo-star perl6 -v

The Perl 6 Tricks and Treats newsletter has been around for a while. If you are interested to get special notification when there is new content on this site, it is the best way to keep track:
Full name:
This is a newsletter temporarily running on my personal site ( using Mailman, till I implement an alternative system in Perl 6.
Gabor Szabo
Written by Gabor Szabo

Published on 2018-06-07


In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus
Suggest a change
Elapsed time: 2.16994348

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.