Category Archives: Geek

All my geek outs

Containers: Resurrection vs. Reincarnation

This post is to share that I am coining new analogy about containers, cloud and orchestration. Everyone uses Pet vs. Cattle, some use Ant. vs. Elephant. These animal analogies are fine and describe how YOU behave to your machines/containers if something bad happens.

But it's also important to look at things from the other side - what actually happens to the app? How does it feel? How does it perceive world around itself?

Resurrection

In a good old Mode1 world things were simple. Some app died, so you went and resurrected it back to life. Sure, PID was different, but it was the same machine, same environment, same processes around it. Feels like home...

Reincarnation

Then the cloud and container world appeared and people realised they don't want to bring dead things back to life (it might have something to do with all the scary zombie movies, I think). And so in container orchestration you just get rid of things that appear to be dead and then bring new ones to life. And you app is reincarnated instead of resurrected

Resurrection vs. Reincarnation.

Reincarnation is not completely new in IT world - it was already used in MINIX many years ago:). But I am coining this new analogy for containers context. Obviously, it's up to you now to share the wisdom and make sure people know who was the original prophet!

Forget resurrection, reincarnation is a way to go!

 

Taskwarrior in a Docker container

So I heard about great tool - Taskwarrior. Cool, let's try it. Well, sure, but why should I install another bunch of RPMs to my laptop? Not that it matters a lot, but I hate to have my system bloated with unused packages which are installed as dependencies, but stay there when I remove the "root" package. Let's go crazy and create a simple Taskwarrior container.

I started with plain Dockerfile.

FROM fedora
MAINTAINER Vaclav Pavlin <vpavlin@redhat.com>
RUN dnf -y install task
VOLUME /task_data
ENTRYPOINT ["task"]

 

That was not ideal because the final container missed very important settings - data location. So I added 2 lines which initialized ~/.taskrc and changed the data location to a well known path. I also added man command to the mix so that I can display manual pages for Taskwarrior. Final Dockerfile follows

FROM fedora
MAINTAINER Vaclav Pavlin <vpavlin@redhat.com>
RUN dnf -y install task man
VOLUME /task_data
RUN yes | task || true
RUN sed -i 's#\(data.location=\).*#\1/task_data#' ~/.taskrc
ENTRYPOINT ["task"]

Still pretty simple, isn't it? Now, how to run this image? Just call the following command, there is an image ready for you on Docker Hub:

docker run -it --rm -v $HOME/.task:/task_data vpavlin/task

The command above will start a container which will initialize few files in $HOME/.task directory and print output like this:

[task next]
No matches.

You can try some fancy stuff with Taskwarrior itself now:

Screenshot from 2015-08-18 16-40-32Well, it works. But also is pretty ugly. Let's make the user experience nicer and smoother. You can simply create an alias for docker run command. For example like this one:

$ alias task="docker run -it --rm -v $HOME/.task:/task_data vpavlin/task"
$ task
[task next]

ID Age Project Tag Description Urg 
 1 6s vpavlin.eu blog today This is a test taks for my blog post 1.9

1 task

Then, when you call task, you will get the same output as if Taskwarrior was installed on you machine. Also your data will be stored locally so you don't have to be afraid of losing them when you remove container/image.

I also wrote a simple task function which you can paste in your ~/.bash_aliases file which lets you either use Taskwarrior as with the alias above, or you can do

task CMD man task

Note CMD in the command - that will let the bash function know to run different command than the one specified in Dockerfile - f.e. view the man pages.

I also strongly suggest to set the data location (i.e. the volume mount, or $data_dir variable in the function) to a backed up folder. I, for example, use Dropbox, so that I can access and modify my tasks from any machine (basically just by pulling and running the Docker image).

Links:

 

Why have I backed Pebble Time?

News! Awesome news! Pebble, the best smart watch maker in the world, announced new version of the watch yesterday. The name Time perfectly fits and I am proud and happy to be one of the first (thousands) backers.

I've been very interested in Pebble since their announcement on Kickstarter in 2012. I wanted to back Pebble back then but was not convinced enough. Two years later I caught myself browsing Pebble's web and hitting Buy button for basic black watch.

They arrived and I happily used them for few weeks. Then display died. I was sad so I asked Pebble what to do about it and the result was new replacement watch in a week on my hand. Awesome customer care, thank you Pebble!

Snímek z 2015-02-24 23:02:32

And here we are at the dawn of the year 2015 and I am finally backing their cool new product again on Kickstarter (Back to the roooots!) and I can't wait till May when they plan to start shipping Pebble Time. I don't need new watch, sure, but they hit the right note - color display, thinner design, new UI, possible hardware extensions... I was not thinking a single minute of switching to Android Wear from my Pebble a single minute and similarly, it took me a minute to figure out I'll back new Pebble Time. And from the numbers at Kickstarter, I was not the only one.