Back in 2016, I created a pokemon Python module (Github) for the sole purpose of converting images to ascii, and then creating a small client to catch pokemon and generate pokemon “avatars” given an identifier. I came back on my package to do some updating (Python 3!) and had an awesome idea!

Let’s containerize the pokemon!

At this point I faced a conundrum that many developers face on a daily basis - What container technology do I use?. I usually cave and generate a Dockerfile and a Singularity build recipe for a repository, but this time I had a great insight! With a Scentific Filesystem (SCIF), I can create a common pokemon.scif recipe that can work to build both containers. Why? Because you can install a SCIF across container technologies, from the same stuff. It comes down to, for each, having an entry point to execute scif, and then installing this scif client along with the recipe. That looks like this

pip install scif
scif install /pokemon.scif

And then the entry point (for Docker, this is the ENTRYPOINT and for Singularity the %runscript) just executes scif. Since the applications are defined by a common scif recipe (in this case a file called pokemon.scif), if I make changes to the applications I don’t need to edit the Dockerfile or Singularity recipe. I can just edit the single pokemon.scif file, push to Github, and both my automated builds get set off. This is the lazy developer’s dream! Now let’s play with these containers. For fun, we are going to run them side by side.

Build

If you want to use them yourself, you can clone the repository and build on your own:

git clone https://www.github.com/vsoch/pokemon
cd pokemon

# Docker
docker build -t vanessa/pokemon .

# Singularity
sudo singularity build pokemons Singularity

The image is available for you already on Docker Hub and Singularity Hub. For Singularity, you might want to pull the image first (so it isn’t created in a temporary directory).

singularity pull --name pokemons shub://vsoch/pokemon

Catch a Pokemon!

Let’s catch a Pokemon! In the example below, we first reference a Docker image using the uri, and the same Singularity image downloaded as an executable called pokemons. I’m going to omit the Pokemon Ascii so you can view them in your own console in all their glory. First let’s catch a random pokemon:

# Docker
docker run vanessa/pokemon run catch

# Singularity
./pokemons run catch
[catch] executing /bin/bash /scif/apps/catch/scif/runscript
...

But I might want to see a huge list of all 721 that I might catch (truncated for brevity):

docker run vanessa/pokemon run list
./pokemons run list
...
Goodra
Klefki
Phantump
Trevenant
Pumpkaboo
Gourgeist
Bergmite
Avalugg
Noibat
Noivern
Xerneas
Yveltal
Zygarde
Diancie
Hoopa
Volcanion

What about the dinosaurs?

./pokemons run list | grep saur
Bulbasaur
Ivysaur
Venusaur

If I see one that I like (the Venusaur of course!), I can catch specifically him:

docker run vanessa/pokemon run catch Venusaur
./pokemons run catch Venusaur
[catch] executing /bin/bash /scif/apps/catch/scif/runscript Venusaur
...```

You could suppress the first line print with --quiet

./pokemons --quiet run catch Venusaur

Behind the scenes, the command being run is scif run catch, and then the environment is activated for the scif application called “catch,” and it’s runscript executed. This is why it works in both Docker and Singularity (and anywhere else a SCIF is installed). Although we don’t do it here, another really awesome thing is that SCIF apps can reference and call one another, completely through environment variables and a predicible filesystem organization.

Generate your Avatar!

The set of 721 Pokemon are great, but I want to know which one is my Pokemon! Let’s create an avatar that is specific to an alias. I’ll use my slack alias, “v”.

# Docker
docker run vanessa/pokemon run avatar v

# Singularity
./pokemons run avatar v
[avatar] executing /bin/bash /scif/apps/avatar/scif/runscript v
...

That was fun! Nevermind I was doing something else and it’s two hours later :) Also note that the recipes aren’t optimized - I install pokemon in the main build recipes from pip, and this might be better done if installed as a SCIF application itself. We have a lot more coming up with the Scientific Filesyste, and for now here are some places to learn more. If you have ideas or want to contribute, please post an issue or reach out!

Learn More about SCIF

Please be responsible and put your Pokemon in containers, friends!