rkt

rkt

1.安装rkt

# wget https://github.com/rkt/rkt/releases/download/v1.30.0/rkt-v1.30.0.tar.gz
# tar zxvf rkt-v1.30.0.tar.gz
# cd rkt-v1.30.0
# cp rkt /usr/local/bin

2. 安装acbuild

# wget https://github.com/containers/build/releases/download/v0.4.0/acbuild-v0.4.0.tar.gz
# tar zxvf acbuild-v0.4.0.tar.gz
# cd acbuild-v0.4.0
# cp * /usr/local/bin

3. 创建一个go镜像

# mkdir hello
# vi hello.go
package main

import (
	"log"
	"net/http"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		log.Printf("request from %v
", r.RemoteAddr)
		w.Write([]byte("hello
"))
	})
	log.Fatal(http.ListenAndServe(":5000", nil))
}

4. build

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

5. 创建镜像

acbuild begin
acbuild set-name example.com/hello
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 <carly@example.com>"
acbuild write hello-0.0.1-linux-amd64.aci
acbuild end

6. run

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

报错:

[root@node44 hello]# rkt --insecure-options=image run hello-0.0.1-linux-amd64.aci
run: open /usr/lib/rkt/stage1-images/stage1-coreos.aci: no such file or directory

解决:

将rkt安装包中的aci结束的镜像拷贝到/usr/lib/rkt/stage1-images/中
原文地址:https://www.cnblogs.com/zhangjxblog/p/12168329.html