- 构建本地镜像
- 编写 Dockerfile 将练习 2.2 编写的 httpserver 容器化
- 将镜像推送至 docker 官方镜像仓库
- 通过 docker 命令本地启动 httpserver
- 通过 nsenter 进入容器查看 IP 配置
作业需编写并提交 Dockerfile 及源代码。
DockerFile:
FROM golang:1.17 AS build WORKDIR /httpserver/ COPY . . ENV CGO_ENABLED=0 ENV GO111MODULE=auto ENV GOPROXY=https://goproxy.cn,direct RUN GOOS=linux go build -installsuffix cgo -o httpserver main.go FROM busybox COPY --from=build /httpserver/httpserver /httpserver/httpserver EXPOSE 8888 ENV ENV local WORKDIR /httpserver/ ENTRYPOINT ["./httpserver"]
本机启动、运行:
推送到阿里云http://registry.cn-hangzhou.aliyuncs.com/jjnnzb/httpserver:0.0.1: