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.

With Go 1.4:

$ CGO_ENABLED=0 GOOS=linux go build -o hello -a -installsuffix cgo .

or with Go 1.5:

$ CGO_ENABLED=0 GOOS=linux go build -o hello -a -tags netgo -ldflags '-w' .

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 on port 5000 and ready to handle HTTP requests.

You can also run rkt as a daemon.

Test with curl

Open a new terminal and run the following command:

$ curl

When curl Fails to Connect

If you're running in Vagrant, the above may not work. You might see this instead:

$ curl
curl: (7) Failed to connect to port 5000: Connection refused

Instead, use rkt list to find out what IP to use:

# rkt list
885876b0	hello	running	default:ip4=

Then you can curl that IP:

$ curl