Getting Started with rkt

The following guide will show you how to build and run a self-contained Go app using rkt, the reference implementation of the App Container Specification. If you're not on Linux, you should do all of this inside the rkt Vagrant.

Create a hello go application

package main

import (

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        log.Printf("request from %v\n", r.RemoteAddr)
    log.Fatal(http.ListenAndServe(":5000", nil))

Build a statically linked Go binary

Next we need to build our application. We are going to statically link our app so we can ship an App Container Image with no external dependencies.

$ CGO_ENABLED=0 go build -ldflags '-extldflags "-static"'

Before proceeding, verify that the produced binary is statically linked:

$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped
$ ldd hello
    not a dynamic executable

Create the image

To create the image, we can use acbuild, which can be downloaded via one of the releases in the acbuild repository

The following commands will create an ACI containing our application and important metadata.

acbuild begin
acbuild set-name
acbuild copy hello /bin/hello
acbuild set-exec /bin/hello
acbuild port add www tcp 5000
acbuild label add version 0.0.1
acbuild label add arch amd64
acbuild label add os linux
acbuild annotation add authors "Carly Container <>"
acbuild write hello-0.0.1-linux-amd64.aci
acbuild end


Launch a local application image

# rkt --insecure-options=image run hello-0.0.1-linux-amd64.aci

Note that --insecure-options=image is required because, by default, rkt expects our images to be signed. See the Signing and Verification Guide for more details.

At this point our hello app is running and ready to handle HTTP requests.

To stop the container, pass three escape characters (^]^]^]), which is generated by Ctrl-] on a US keyboard. You can also run rkt as a daemon.

Test with curl

By default, rkt will assign the running container an IP address. Use rkt list to discover what it is:

# rkt list
885876b0    hello running default:ip4=

Then you can curl that IP on port 5000:

$ curl