GoManilaPh
October 2018
GoManilaPh
October 2018
Regional Director of Engineering
Freelancer.com
GoManilaPh
October 2018
GoManilaPh
October 2018
... a computer program that performs operating-system-level virtualization, also known as containerization.
GoManilaPh
October 2018
GoManilaPh
October 2018
| namespace | purpose |
|---|---|
| PID | process isolation |
| NET | managing network interfaces |
| IPC | managing access to IPC resources |
| MNT | managing filesystem mount points |
| UTS | isolating kernel and version identifiers |
GoManilaPh
October 2018
| cgroup | purpose |
|---|---|
| Memory | managing accounting, limits and notifications |
| HugeTBL | accounting usage of huge pages by process group |
| CPU | managing user / system CPU time and usage |
| CPUSet | binding a group to specific CPU |
| net_cls/net_prio | tagging the traffic control |
| Devices | reading / writing access devices |
| Freezer | freezing a group |
GoManilaPh
October 2018
Filesystem Isolation (rootfs/chroot)
Layering
Copy-on-Write
Caching
Diff'ing
GoManilaPh
October 2018
GoManilaPh
October 2018
GoManilaPh
October 2018
GoManilaPh
October 2018
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "<h1>Hello GoManilaPh</h1>")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
GoManilaPh
October 2018
GoManilaPh
October 2018
FROM golang:1.11.1
COPY . /src
WORKDIR /src
RUN go build
EXPOSE 8080
CMD /app/golang-docker
GoManilaPh
October 2018
FROM golang:1.11.1-alpine as builder
RUN apk update && apk add g++ gcc make musl
COPY . /src
WORKDIR /src
RUN go build -o entrypoint
FROM alpine
COPY --from=builder /src/entrypoint /entrypoint
EXPOSE 8080
ENTRYPOINT [ "/entrypoint" ]
GoManilaPh
October 2018
FROM golang:1.11.1 as builder
COPY . /src
WORKDIR /src
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
go build -o entrypoint -ldflags '-w -s' main.go
FROM scratch
COPY --from=builder /src/entrypoint /entrypoint
EXPOSE 8080
ENTRYPOINT [ "/entrypoint" ]
GoManilaPh
October 2018