Dockerizing Taskwarrior

In my path towards dockerizing everything in my laptop, I wrote another Dockerfile to build my taskd-server container service. And yeah, if you don’t know what this little jewel is, Taskwarrior is just your todo list manager, flexible, fast, efficient; it captures tasks, shows you the list and removes tasks from that list, but it also has many great features, for example it could become a sophisticated data query tool that can help you stay organized, and get through your work.
As I said taskw has several strengths and the one I like very much is the ability to organize tasks in a user-defined hierarchy (by project, by date, by priority); when your list become so long, I think you can appreciate the query system, so the good news is that you can write your own functions (combining the task-cli commands) to display things as you prefer, for instance this little peace of code show how you can combine the ls and the summary commands to display tasks by project name:

if [[ -z "$1" ]]; then
    task list && task summary
    task list project:$1 && task summary project:$1

But now it’s time to talk about the server side level.
First of all, you can find the Dockerfile on my github but you can just skip this check pulling the container from the dockerhub:

$ docker pull fmount/taskd

The default image generates a container that runs the server on localhost:53589.
In order to expose the service, you need to modify the taskd server conf and run it on, so the conf definitively looks like:


The image also stores configuration and data in /var/taskd, which you should persist somewhere, so you can run it mounting your own data to the taskd server:

$ docker run --name "the_magical_tomato" -p 53589:53589 \
	-v /home/user/taskd-srv:/var/taskd:Z fmount/taskd:1.2.0

or you can start the docker container without any volume:

$ docker run --name "the_magical_tomato" -p 53589:53589 fmount/taskd:1.2.0

and then copy all client conf from the /var/taskd:

$ docker cp the_magical_tomato:/var/taskd/client.cert.pem
$ docker cp the_magical_tomato:/var/taskd/client.key.pem
$ docker cp the_magical_tomato:/var/taskd/ca.cert.pem

But … before copying the file client* and ca.cert mentioned above, you need first to create a tenant and the related user(s) to sync from the server, so you need to attach to the container:

$ docker exec -it the_magical_tomato /bin/bash

and add a Group/user:

$ taskd add org MyOrganization
$ taskd add user 'MyOrganization' 'myuser'

Finally, just generate the correct keys for the user client, so going to:

$ cd /opt/taskd/pki

generate the client.* launching:

$ ./generate.client 'myuser'

This will generate a new key and cert, named myuser.cert.pem and myuser.key.pem. It is not important that ‘myuser’ was used here, just that it is something unique, and valid for use in a file name. It has no bearing on security.

Once the container is running and you see the exposed port (ss command is your friend), you can finally configure your client adding to taskrc the following:


Here some useful doc I found to build the container and configure my clients:

Finally, a last interesting note on this post is related to a tmux layout I made in order to show some infos about the status of task activities; following this GIST you can find the tmux layout provided and, according to my last project Tmux layout plugin, you can load it putting it in the ~/.tmux/plugins/tmux-layout/layouts.

comments powered by Disqus