A few weeks ago I stumbled upon an interesting hackernews discussion about setting up development environments: from what I could tell it seemed like most people have been ditching Vagrant and VMs in order to move towards docker containers, through docker-compose or minikube.
Compose, to be fair, provides a painless user experience and allows you to extend
your Dockerfiles to be able to run containers with specific “dev” settings, like
local volumes and different commands (think
node index.js vs
What if we could have a similar experience with rkt?
All in all, what you need to run docker containers locally are:
- a bunch of binaries (
- a file to build your production image (
- a file to extend that image with some dev settings (
Since I wanted to play with rkt and I couldn’t find an easy way to maintain the same workflow I had using docker, I decided to build a small tool called rkd (rkt dev) that can help you achieve the same exact productivity you’d have using docker and docker-compose. This is an early-stage experiment1 and, as such, things might break here & there.
Let me recap it: like we’d do with docker, we’ll first need to download a bunch of binaries, then create a file that describes our production container and, last but not least, define our dev settings in another file.
If the whole thing takes longer than 5 minutes we fail, so let’s get to it!
Step 0: our sample NodeJS app
Create a brand new folder in your fs (
path/to/my/app), a subfolder
1 2 3 4 5 6
No rocket science.
Step 1: binaries
We will need to download binaries for our platform of 3 tools:
- rkt, the container engine
- acbuild, the tool that’s used to build ACIs, which are containers images that rkt can run
- rkd, a tool I’ve built to be able to automate building & running rkt containers
Once you’ve grabbed the binaries you can test them by running
Step 2: writing a “Dockerfile”
In order to build ACIs we would need to run a bunch of shell commands such as:
1 2 3 4 5 6 7 8
but that’s a hella lot of commands and being repetitive is no fun at all — we
can automate this task with
Let’s create a
1 2 3 4 5 6 7
Here we’re describing how our “production” container should look like, similarly to what we’d do with a Dockerfile:
1 2 3 4 5 6
As you see, the syntax is extremely similar, you just need to familiarize with
After writing our
prod.rkd we are ready to extend it with our own development
Step 3: writing a “docker-compose.yml”
docker-compose.yml will instead be named
dev.rkd, and we just need a
couple instruction in it to mount our local code and change the executable that
is used to run the container:
1 2 3
Nothing more, nothing less: we are now ready to rock!
Let’s run our app!
In order to build the ACIs and run them in “dev” mode we simply need to type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
Then open localhost:8080 on your browser and…
I hope you enjoyed this article and are excited about the progress made by rkt in order to provide a viable alternative to docker. I wrote rkd in a few hours and it really is just a wrapper around acbuild & rkt, so kudos to those guys.
In my opinion, rkt is still quite behind docker but they’re filling the gaps, getting closer as the days go by — it won’t be long until we’ll be realistically able to switch over without “feeling” the difference.
- I’ve been working on rkd during weekends, at conferences and over public WiFis, so you can imagine… :) ↩